PHPackages                             jijihohococo/ichi - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. jijihohococo/ichi

ActiveProject[Framework](/categories/framework)

jijihohococo/ichi
=================

Ichi PHP MVC Framework

1.5(2mo ago)125MITPHP

Since Feb 24Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/jijihohococo/ichi)[ Packagist](https://packagist.org/packages/jijihohococo/ichi)[ RSS](/packages/jijihohococo-ichi/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (10)Versions (4)Used By (0)

ICHI PHP FRAMEWORK
==================

[](#ichi-php-framework)

ICHI PHP FRAMEWORK is a fast and secure MVC PHP framework.

License
-------

[](#license)

This framework is open source under the [MIT license](LICENSE.md).

Table of Contents
-----------------

[](#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
------------

[](#installation)

```
composer create-project jijihohococo/ichi your_project
```

Setup
-----

[](#setup)

First, you must create a `.env` file in your project folder. Then declare your actual database name, database username, and password in that file.

**You can see the required format in `.env.example` under your project folder.**

*In your `.env` file*

```
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 the public path:

```
your_project/public > php -S localhost:8000
```

Using
-----

[](#using)

### Route

[](#route)

You can add routes in the `web` function of `routes/web.php`.

If you want to add another route file, create a new file under the `routes` folder. Then add a new function similar to `web.php`.

```
function new_routes($route)
{

}
```

Then include your new route file in `app/Kernel.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();
	}
}
```

**The code above highlights what is needed to add a new route file.**

You can use [this documentation](https://github.com/jijihohococo/ichi-route/blob/master/README.md) for route functions in detail.

### Middleware

[](#middleware)

You can create middleware for routes from the command line.

```
php ichi make:middleware NewMiddleware
```

The middleware class will be created under the `app/Middleware` folder.

You can use [this documentation](https://github.com/jijihohococo/ichi-route#middleware) for middleware functions in detail.

### Model

[](#model)

You can add another database connection in `app/Kernel.php`, as shown in [this documentation](https://github.com/jijihohococo/ichi-orm/blob/master/README.md#set-up-database-connection).

You can create a model from the command line.

```
php ichi make:model NewModel
```

The model class will be created under the `app/Models` folder.

*Example model*

```
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](https://github.com/jijihohococo/ichi-orm/blob/master/README.md) for model usage details.

### Controller

[](#controller)

You can create a controller from the command line.

```
php ichi make:controller NewController
```

The controller class will be created under the `app/Controllers` folder.

For more details, use [this documentation](https://github.com/jijihohococo/ichi-route/blob/master/README.md#creating-controller).

### View

[](#view)

You can create a view component class from the command line.

```
php ichi make:component ViewComponent
```

The view component class will be created under the `app/Components` folder.

You can return a view in a route callback or in a controller method.

*Without controller*

```
$route->get('/welcome',function(){
	return view('welcome.php');
});
```

*With controller*

```
$route->get('/welcome','HomeController@welcome');
```

```
namespace App\Controllers;

class HomeController
{
	public function welcome()
	{
		return view('welcome.php');
	}
}
```

You must create view PHP files under the `resources/views` folder.

For more details, use [this documentation](https://github.com/jijihohococo/ichi-template/blob/master/README.md).

### Validation

[](#validation)

You can validate input data in your controller class.

```
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 display validation error messages in your view PHP file:

```
