juneszh / alight-project
Alight Project is a project template with Alight framework.
Requires
- php: >=8.3
- juneszh/alight: ^3.0
Requires (Dev)
- phpstan/phpstan: ^2.1
README
Alight-Project is a project template for the Alight framework. It provides a ready-to-use application structure and can be extended with an admin panel powered by Alight-Admin.
Alight Family
| Project | Description |
|---|---|
| Alight | Basic framework built-in routing, database, caching, etc. |
| Alight-Admin | A full admin panel extension based on Alight. No front-end coding required. |
| Alight-Project | A template for beginner to easily create web applications by Alight/Alight-Admin. |
Requirements
PHP 8.3+
Usage
$ composer create-project juneszh/alight-project {PROJECT_DIRECTORY}
Directory Structure
app/Contains the core code of your application.controller/Contains controllers that handle requests (MVC pattern).job/Contains jobs run by the time-based scheduler.model/Contains models of database (MVC pattern).service/Contains the business logics.view/Contains views with page templates (MVC pattern).bootstrap.phpThe web bootstraps.scheduler.phpJob scheduler run by CRON.
config/Contains all of application's configuration files.admin/Contains the admin's menu and console configuration after Alight-Admin is installed.route/Contains the route's configuration.app.phpApplication's configuration.job.phpJob scheduler's configuration.
public/Contains the index.php file and assets such as images, JavaScript, and CSS.favicon.icoIcon for the web application.index.phpEntry point for all requests entering the web application.
storage/Contains logs, route caches, file caches, and other files generated by the framework.vendor/Contains composer dependencies.
Shortcut Namespaces
The classes in the application are always called from the business code, so we define some shortcut namespaces to improve coding efficiency.
| Namespace | Directory |
|---|---|
ctr |
app/controller |
job |
app/job |
mod |
app/model |
svc |
app/service |
For example:
// The route handler points to method 'index' in app/controller/Page.php Alight\Route::get('/', [\ctr\Page::class, 'index']);
Composer Scripts
The admin panel is not installed when a project is created. Configure the database, then run:
$ cd {PROJECT_DIRECTORY}
$ composer require juneszh/alight-admin
$ composer run admin-install
$ composer run admin-download
List of scripts:
| Name | Description |
|---|---|
admin-install |
Initialize the runtime environment required by the Alight-Admin. |
admin-build |
Build the admin panel front-end resources by npm packages. (Node.js required) |
admin-download |
Download the admin panel front-end resources from Alight-Admin releases. |
Development
Validate Composer metadata, PHP syntax, and PHPStan before committing changes:
$ composer check
Run an individual check with composer lint or composer analyse.
When developing against an unpublished sibling Alight checkout, run:
$ ALIGHT_SOURCE_DIR=../alight/src composer check
Repository architecture and AI coding-agent instructions are documented in AGENTS.md and docs/architecture.md.