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

v1.0.5 2025-03-03 21:47 UTC

This package is auto-updated.

Last update: 2025-05-31 00:30:21 UTC


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

  1. Fork the repository.
  2. Make your changes.
  3. 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