Coder Social home page Coder Social logo

ichi's Introduction

ICHI PHP FRAMEWORK

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

License

This framework is Open Source According to MIT license

Table Of Contents

Installation

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

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

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'.

function new_routes($route){

}

Then you must use 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();
	}



}

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 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 ichi make:model NewModel

The Model Class will be created under '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 to use Model in detail

Controller

You can create Controller in command line.

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 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

$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 file under 'resources/views' folder.

For more detail, use this documentation.

Validation

You can validate the 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 call your validation error messages in your view php file


<?php if(isset($errors['name'])): ?>
<?php echo $errors['name']; ?>
<?php endif; ?>

For more detail, use this documentation.

ichi's People

Contributors

jijihohococo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.