Download the PHP package jijihohococo/ichi-route without Composer

On this page you can find all versions of the php package jijihohococo/ichi-route. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ichi-route

ICHI PHP ROUTER

ICHI PHP ROUTER is aimed to be the fast PHP Router with ease to use and protecting the security vulnerabilities

License

This package is Open Source According to MIT license

Table Of Content

Installation

Setting

You must create following htaccess file before setting route according to your server.

Apache

Create .htaccess file in your based folder

Nginx

Create .htacess file in your based folder

Creating Controller

You must create the controller for your routes.

Firstly you need to created the file named "ichi" under your project folder and use the below code in this file

And then you can create the controller in your commandline

The default file folder is "app/Controllers". So after making command, the controller you created will be in the this default file folder. If you want to change the default folder path, you can change it in your "ichi" file.

Single Route

You can add routes with "get","post","put","delete" and "head" functions.

Each function represents the each route method

You can add route with closure function or the function of controller class.

With closure function

With Controller class

You must autoload your the controller folder before using the route function in your composer.json

If you have the same controller path for all controllers, you can set base controller path for all routes before adding routes.

To run all of your routes, you must use "run()" function.

You must use "run()" function after declaring all routes for your system

After running route function, the routes (URL) are able to run

PATCH Method

To make PATCH method , you need request and add 'PATCH' values in this. And the action must 'POST'.

In your route

For the form data

PUT Method

To make PUT method , you need request and add 'PUT' values in this. And the action must 'POST'.

In your route

For the form data

DELETE Method

To make DELETE method , you need request and add 'DELETE' values in this. And the action must 'POST'.

In your route

For the form data

Using Routes

Calling routes in frontend

Route Parameter

In many cases, you have a time to make route parameters

In your controller class

You can also do with closure function

After running route function, the routes (URL) are able to run

Calling routes in frontend

Resource Route

You can CRUD routes with one route method

In your controller class

You can also create the resource controller in terminal after making according to the insturctions from Creating Controller

After running route function, the routes (URL) are able to run

You can also create the api resource controller in terminal after making according to the insturctions from Creating Controller

After running route function, the routes (URL) are able to run

Prefix Route

You can use prefix route to make groups

So the below url are able to use

You can add the routes in the group closure function.

Don't include '/' in declaring "url_group"

Subdomain Route

You must set your main domain name before declaring routes if you want to use subdomains.

Single Subdomain

You can set your subdomain routes with "domain()" function

You can use all route functions within "domain()" function

You can't use domain function within group function

If you want to show your subdomain route, use getSubdomainRoute function. First parameter is domain name and second parameter is declared route under this subdomain.

Subdomain Parameter

If you want to use parameter in your subdomain

Parameters are embrace with "{" and "}" as route parameters

You must pass subdomain parameters into the closure function or class's function

Class's function

Closure function

If you want to use multiple subdomain parameters, use '.' between parameters and string

Class's function

Closure function

If you want to use route parameters in subdomain parameters, You must pass subdomain parameters and also route parameters in your class's function or closure function

Class's function

Closure function

If you want to get subdomain parameters in your middleware which are under that subdomain routes

In your middleware class

You can't pass subdomain parameters into your middleware like you can do with your route parameters

Dependency Injection

You can make dependency injection with controller class.

You must have interface and class according to the below format

Your interface and class must be autoloaded

Interface Class
ItemInterface Item
ItemRepositoryInterface Item Repository

The functions of class that dependency injected will automatically run

In your controller class

You can also add another dependency injection in your repositories.

Middleware

You can add middlewares in single route like below

You must delcare middleware class

Your middleware classes must be autoloaded in composer as we mentioned before

You must extend JiJiHoHoCoCo\IchiRoute\Middleware\MainMiddleware and add "handle()" function. In your "handle" function, you must always return "next()" function. You can check your business transactions in this "handle" function.

You can create the middleware via terminal after creating "ichi" file as we mentioned in Creating Controller

The default path for observer is "app/Middlewares". You can also change this in "ichi" file.

You can add multiple middleware classes

Those middlewares will be loaded sequently because of using "next()" function in each "handle()" function.

You can add parameters in middleware with your route parameters

In your middleware class

You can add multiple parameters in middleware with your route parameters

In your middleware class

You can add middlewares in prefix routes like the way you do in single routes and parameter routes

You can add only middleware in prefix routes.

If you have the same middleware path for all middlewares, you can set base middleware path for all routes before adding routes.

There are some middlewares that already written in this library. For those middlewares you must declare their middleware path completely.

If you have the middlewares that you want to check for all routes

If you don't delcare base middleware path

If you declare base middleware path

CSRF Token Authentication

You can protect create and update route with CSRF Token Authentication

You must generate CSRF Token before declaring the routes

You can add JiJiHoHoCoCo\IchiRoute\Middleware\CSRFMiddleware in your prefix routes too.

In your frontend php file

API Request Authentication

You can add middleware to accept only API request for your route

To pass JiJiHoHoCoCo\IchiRoute\Middleware\APIMiddleware, you must add "application/json" value in your "Content-Type" header when you request that api route

CORS

You can make CORS to get your data from another domains

You can make options for your CORS with JiJiHoHoCoCo\IchiRoute\Setting\CORS

Caching Route

You can cache parameter routes with

  1. Database
  2. Redis
  3. Memcached

You must do following instructions before adding routes

Caching with Database

You must run this SQL code to create "ichi_routes" table in your database

And add your pdo object with expired time in seconds

You can also make without expired time

Caching with Redis

Add your redis object with expired time in seconds

You can also make without expired time

Caching with Memcached

Add your memcached object with expired time in seconds

You can also make without expired time

Error Page Customization

You can call the error page (whatever it is default or customized)

Default eror message is "404 - URL is not found". Default HTTP response code is 404.

You can customize error message and HTTP response code

If you don't like the default error page from this library,you can show the own error page

If you want to show more specific error according to your HTTP response code, you must create a function

In your customized function, you must have "$message" and "$code" parameters


All versions of ichi-route with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0 || >=8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jijihohococo/ichi-route contains the following files

Loading the files please wait ....