PHP code example of codad5 / php-inex

1. Go to this page and download the library: Download codad5/php-inex library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

codad5 / php-inex example snippets


    
    $export = function(){
        echo "hello";
    }
    

    
        PhpInex\Import;
        $greeting = Import::this('Export');
        $greeting(); // hello
    

    
    $export['greet'] = function(){
        echo "hello";
    }

    $export['sum'] = function($a, $b){
        return $a + $b;
    }
    

    
        PhpInex\Import;
        ["greet" => $greet, "sum" => $sum] = Import::this('Export');
        $greet(); // hello
        echo $sum(2,4) // 6
    

    
    o\PhpRouter\Router as Router;
    $route = new Router();
    $route->get('/food', function($req, $res){
        $res->json([
            'name' => "rice"
            ]);
    });
    $export = $route;
    

    
    o\PhpRouter\Router as Router;
    use Codad5\PhpInex\Import;

    $route = new Router();
    $apiRoute = Import::this('routes/api');
    
    $route->get('/', function($req, $res){
        $res->send('welcome');
    });
    $route->set_route('/api', $apiRoute);
    
    // serving the application
    $route->serve();
    

composer