https://github.com/jijihohococo/ichi
PHP MVC Framework
https://github.com/jijihohococo/ichi
open-source php php-framework php-mvc php-mvc-framework
Last synced: 4 months ago
JSON representation
PHP MVC Framework
- Host: GitHub
- URL: https://github.com/jijihohococo/ichi
- Owner: jijihohococo
- License: mit
- Created: 2022-02-06T22:59:22.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-06T15:29:56.000Z (almost 2 years ago)
- Last Synced: 2024-12-29T11:31:11.659Z (about 1 year ago)
- Topics: open-source, php, php-framework, php-mvc, php-mvc-framework
- Language: PHP
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ICHI PHP FRAMEWORK
ICHI PHP FRAMEWORK is the fast and secure MVC PHP framework.
## License
This framework is Open Source According to [MIT license](LICENSE.md)
## Table Of Contents
- [ICHI PHP FRAMEWORK](#ichi-php-framework)
- [License](#license)
- [Table Of Contents](#table-of-contents)
- [Installation](#installation)
- [Setup](#setup)
- [Using](#using)
- [Route](#route)
- [Middleware](#middleware)
- [Model](#model)
- [Controller](#controller)
- [View](#view)
- [Validation](#validation)
## Installation
```php
composer create-project jijihohococo/ichi:dev-master your_project
```
## Setup
First, You must create .env file under your project folder. And then you must declare your real database name, database username and password in this .env file.
You can see how to set the data in .env.example under your project folder.
In your .env file
```txt
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_user_name
DB_PASSWORD=your_database_password
```
You can run the app from public path
```txt
your_project/public > php -S localhost:8000
```
## Using
### Route
You can add your route in 'web' function of "routes/web.php".
If you want to add another route file, create new route file under "routes" folder.
And then you must add new function like 'web.php'.
```php
function new_routes($route){
}
```
Then you must use your new route file in 'app/Kernel.php';
```php
namespace App;
use JiJiHoHoCoCo\IchiRoute\Router\Route;
require_once __DIR__ . '/../routes/new_routes.php';
class Kernel{
public function run(){
$route = new Route;
new_routes($route);
$route->run();
}
}
```
Above code is highlighting the things in adding new route file.
You can use this docuementation for the route functions in detail.
### Middleware
You can create middleware for routes in command line.
```php
php ichi make:middleware NewMiddleware
```
The Middleware Class will be created under 'app/Middleware' folder.
You can use this documentation for the middleware functions in detail.
### Model
You can add another database connection in "app/Kernel.php" as shown as this documention .
You can create model in command line.
```php
php ichi make:model NewModel
```
The Model Class will be created under 'app/Models' folder.
Example Model
```php
namespace App\Models;
use JiJiHoHoCoCo\IchiORM\Database\Model;
class NewModel extends Model{
public $id , $name , $created_at , $updated_at , $deleted_at ;
}
```
You can use this documentation to use Model in detail
### Controller
You can create Controller in command line.
```php
php ichi make:controller NewController
```
The Controller Class will be created under 'app/Controllers' folder.
For more detail, use this documentation .
### View
You can create View Component Class in command line.
```php
php ichi make:component ViewComponent
```
The View Component Class will be created under 'app/Components' folder
You can return view in the route or controller's function
Without Controller
```php
$route->get('/welcome',function(){
return view('welcome.php');
});
```
With Controller
```php
$route->get('/welcome','HomeController@welcome');
```
```php
namespace App\Controllers;
class HomeController{
public function welcome(){
return view('welcome.php');
}
}
```
You must create view PHP file under 'resources/views' folder.
For more detail, use this documentation.
### Validation
You can validate the input data in your controller class
```php
namespace App\Controllers;
use JiJiHoHoCoCo\IchiValidation\Validator;
class TestController{
public function test(){
$validator = new Validator();
if(!$validator->validate($_REQUEST,[
'name' => 'required' ,
'age' => 'required|integer' ,
'email' => ['required','email']
])){
setErrors($validator->getErrors());
return view('test.php');
}
}
}
```
You can call your validation error messages in your view php file
```
```
For more detail, use this documentation.