lcsng / amanda
Amanda is a lightweight and flexible PHP routing library that dynamically maps website URLs to template files without requiring manual route definitions or directory structures. Simply place your .php or .html templates inside the amanda_templates/ directory, and Amanda will automatically serve them
Requires
- php: ^8.3
- lcsng/external: ^1.0.1
README
π Amanda is a powerful and flexible PHP routing library that dynamically maps URLs to template files without requiring manual route definitions. It provides a simple yet robust way to handle requests, making web development faster and more efficient.
π Key Features
β
Auto-routing β No need to manually define routes; Amanda maps URLs to templates automatically.
β
Customizable & Lightweight β Easily modify template paths and routing logic.
β
Dedicated Public Directory β Follows best practices by keeping core files separate from publicly accessible assets.
β
Seamless Integration β Works with both existing PHP projects and new installations.
π₯ Installation
1οΈβ£ Install Amanda as a Full Project
Amanda should be installed in a server directory that is not publicly accessible. You can install it using:
composer create-project lcsng/amanda my-site
This will create a my-site/
directory containing all necessary files and folders.
π Folder Structure
Amanda follows this directory setup:
my-site/ # Server directory (not public)
βββ amanda/ # Core framework files (configs, functions, templates, etc.)
β βββ amanda_templates/ # User templates (PHP/HTML)
β βββ amanda_routers/ # Routing logic
β βββ ... (other core files)
β
βββ public_html/ # The document root (publicly accessible files)
β βββ index.php # Handles all requests
β βββ amanda_ajax.php # For AJAX requests
β βββ amanda_assets/ # Public assets (CSS, JS, images, etc.)
β βββ ... (other public files)
β
βββ composer.json # Project dependencies
Folder Placement Notes:
πΉ my-site/
is not the document rootβit is the server directory.
πΉ public_html/
is the document root, where web requests are directed.
πΉ Users can place Amanda anywhere that fits their project structure.
π Getting Started
1οΈβ£ Place Your Templates
Simply put your .php
or .html
files inside the amanda/amanda_templates/
directory. Amanda will automatically route them based on the requested URL.
For example:
amanda_templates/
βββ home.php β Access via `/home`
βββ about.html β Access via `/about`
βββ contact.php β Access via `/contact`
βββ 404.html β Default 404 error page
2οΈβ£ Configure Routing (Optional)
Modify the amanda_routers/artd.php
file to override defaults:
$amanda_router->template_dir = AMANDA_TEMPLATE_DIR; $amanda_router->error_404 = AMANDA_TEMPLATE_DIR . '/404.html'; // Custom template overrides $amanda_router->home = AMANDA_TEMPLATE_DIR . '/home2.php'; $amanda_router->add_template = [ 'cart' => AMANDA_TEMPLATE_DIR . '/cart.php' ];
π Documentation
For full documentation, visit lcs.ng/amanda.
π€ Contributing
- Fork the repository.
- Make your changes.
- Submit a pull request.
π License
Amanda is licensed under GPL-3.0-or-later, meaning it is free to use, modify, and distribute while ensuring derivatives remain open-source.
π§ Contact & Support
π Author: Chinonso Frewen Justice (JCFuniverse)
π§ Email: amanda@lcs.ng
π Website: lcs.ng/amanda