vitodtagliente / pure
A fresh and fast PHP micro framework
Installs: 20
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
Requires
- vitodtagliente/pure-core: dev-master
- vitodtagliente/pure-orm: dev-master
- vitodtagliente/pure-routing: dev-master
- vitodtagliente/pure-template: dev-master
This package is auto-updated.
Last update: 2024-11-09 06:21:19 UTC
README
Pure is a PHP fresh and fast micro framework.
How To install and configure
-
Create the project using composer:
composer create-project vitodtagliente/pure ProjectName -s dev
-
Configure the application edititng the files under app/Config
- app/Config/app.ini contains all the application settings
- app/Config/database.ini contains database connection settings
-
Generate the project key with the command
php pure app generate:key
-
Run the application
php -S localhost:8000
How to Update pure
To update the framework and all the dependencies, run the following command:
composer update
Each time the file composer.json is changed, run the following command:
composer dump-autoload
MVC Pattern
Pure follows the MVC pattern, it means that the behaviour is defined by Controllers and routes.
-
Edit the file app/Routes/web.php and define the application routes:
<?php router()->get('/', 'App\\Controllers\\WelcomeController@index'); ?>
-
Put controllers into the path: app/Controllers:
<?php namespace App\Controllers; use Pure\Controller; use Pure\Template\View; class WelcomeController extends Controller { function index(){ view('welcome.php'); } } ?>
-
Define views into app/Views:
<html> <head> <title>pure</title> </head> <body> <h1>Hello Pure!</h1> </body> </html>
Creating Resources
In pure is easy to add resources to the application. Type the following commands on the shell:
- php pure app make:command ControllerName - php pure app make:controller ControllerName - php pure app make:middleware MiddlewareName - php pure app make:model ModelName - php pure app make:schema SchemaName - php pure app make:service ServiceName
-
Create new Commands add command line functions to your application. All commands are called by
php pure 'command_class_name' argument1 argument2 .... argumentN
-
Controllers are used to define the behaviour of the application, following the MVC pattern.
-
Middlewares are not yet implemented (Work in progress)
-
Models define the datatabase data abstraction, look at Pure ORM Component documentation
-
Schemas generate database tables. Schemas can be generated automatically by pure startup if they are registered. Schemas can be registered in 2 ways:
-
Adding the schema class name to the app/Config/app.ini
; put there the Scemas that should be created at startup time ; schemas[]='' schemas[] = 'App\Schemas\UserSchema'
-
Registering the class name directly to the pure application:
$app = \Pure\Application::main(); $app->registerSchema('App\Schemas\UserSchema');
-
-
Services are used to change the application flow
class CustomService extends ApplicationService { public function boot(){ // at the applicatio startup } public function start(){ // before fetching routes } public function stop(){ // at the application exit } }
Like Schemas, Services must be registered to the pure application adding the schema class name to the app/Config/app.ini:
; put there the Application Service classes ; services[]='' services[] = 'App\Services\CustomService'
Customize dependencies
Install packages using composer and customize the application behaviour. pure works on top of 4 components:
Look at their own Documentation