ICHI PHP FRAMEWORK is a fast and secure MVC PHP framework.
This framework is open source under the MIT license.
composer create-project jijihohococo/ichi your_projectFirst, 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_passwordYou can run the app from the public path:
your_project/public > php -S localhost:8000You 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 for route functions in detail.
You can create middleware for routes from the command line.
php ichi make:middleware NewMiddlewareThe middleware class will be created under the app/Middleware folder.
You can use this documentation for middleware functions in detail.
You can add another database connection in app/Kernel.php, as shown in this documentation.
You can create a model from the command line.
php ichi make:model NewModelThe 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 for model usage details.
You can create a controller from the command line.
php ichi make:controller NewControllerThe controller class will be created under the app/Controllers folder.
For more details, use this documentation.
You can create a view component class from the command line.
php ichi make:component ViewComponentThe 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.
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:
<?php if(isset($errors['name'])): ?>
<?php echo $errors['name']; ?>
<?php endif; ?>For more details, use this documentation.