https://github.com/onecthree/zpheur
Zpheur skeleton-application or project template
https://github.com/onecthree/zpheur
framework php php8 skeleton-application web
Last synced: 2 months ago
JSON representation
Zpheur skeleton-application or project template
- Host: GitHub
- URL: https://github.com/onecthree/zpheur
- Owner: onecthree
- License: mit
- Created: 2024-10-18T15:46:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-16T20:34:06.000Z (over 1 year ago)
- Last Synced: 2025-11-27T16:19:13.505Z (4 months ago)
- Topics: framework, php, php8, skeleton-application, web
- Language: PHP
- Homepage:
- Size: 37.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Zpheur Skeleton Application
> ⚠️ Used only for non-production (untested and non-stable release)
Zpheur skeleton application for a new project.
## Installation
> Remember, you must install the [czpheur](https://github.com/onecthree/czpheur) extension before using this template.
To create new project via Composer:
```bash
$ composer create-project onecthree/zpheur new-project
```
## Basic Usage
As a personal project, the framework itself doesn't have many features yet. But for the first try, you can see the sample code on the controller ```app/Http/Action/IndexAction.php```:
```php
class IndexAction extends BaseAction
{
public function __construct( Request $request, Response $response )
{
parent::__construct($request, $response);
}
#[Route\GET(dest: '/')]
public function getIndex( Response $response ): Response
{
return $response->send('Hello World');
}
}
```
### Class autoloader
Zpheur using ```spl_autoloader``` for the class/function autoloader in the framework, for the example how namespacing model work, see bottom example:
```php
// In your project, all application things are located under "app" directory.
// Namespacing in path always begin with lower alphabet, like "app" and "system"
// but namespacing in PHP code always begin with upper alphabet, see "app/Http/Action/IndexAction.php":
send('Hello World');
}
#[Route\POST(dest: '/')]
public function postIndex( Response $response ): Response
{
return $response->send('Hello World');
}
// #[Route\PUT(dest: '/')]
// #[Route\PATCH(dest: '/')]
// #[Route\DELETE(dest: '/')]
// #[Route\OPTIONS(dest: '/')]
}
```
### Compile controllers route
Zpheur router currently only supports precompiled routers, it's actually a cached array in ```system/var/cache/route/source.php``` file. After you create a new controller with route or new route in controllers, run the command under the root project directory to compile the routers:
```bash
$ php bin/console make:route
```
### Dotenv loader
By default, a first installation with Composer will include ```.env.example``` file; you must rename or copy the file to ".env". The Dotenv loader will check if file exists and will do a parsing ```.env``` and load the values use ```putenv()```. But before actually use the value from ```getenv()```, you must cache the ```.env``` file first:
```bash
$ php bin/console make:env
```