PHP code example of sixiaoqi / yaf-support

1. Go to this page and download the library: Download sixiaoqi/yaf-support 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/ */

    

sixiaoqi / yaf-support example snippets


        $app = new Application([], realpath(dirname(__FILE__)));
        Yaf_Registry::set('app', $app);

        $app = new Application([], realpath(dirname(__FILE__)));
        Yaf_Registry::set('app', $app);

        app()['request'] = function ($c) {
            return new Request('test/test', 'base_uri/test/test');
        };

        app()[Authenticate::class] = function ($c) {
            return new Authenticate();
        };

        $app = new Application([], realpath(dirname(__FILE__)));
        \Yaf_Registry::set('app', $app);
        
         app()['request'] = function ($c) {
                $request = new Request('test/test', 'base_uri/test/test');
                $request->setShouldMethod('any');
                $request->setMiddleware(['auth']);
                $request->setParam('api_token','12345678');
        
                return $request;
         };
        
          app()[Kernel::class] = function ($c) {
                return new Kernel($c);
          };
        
          arrayConfig()->set('auth', 

        if ($middlewareList = $request->getMiddleware()) {
              collect($middlewareList)->map(function ($middleware) {
                   $this->middleware[] = $middleware;
              });
        }
        
        return (new Pipeline($this->app))
               ->send($request)
               ->through($this->middleware)
               ->then(function ($request) {
                    return $request;
        });

         $app = new Application([], realpath(dirname(__FILE__)));
         Yaf_Registry::set('app', $app);
        
         app()['request'] = function ($c) {
              return new Request('cli', 'cli');
         };

         validator()->validate([
              'age'  => '       
         $age  = request()->getParam('age');
         $name = request()->getParam('name', 'test');
         var_dump($age);
         var_dump($name);

         date_default_timezone_set("PRC");
         
         $app = new Application([], realpath(dirname(__FILE__)));
         Yaf_Registry::set('app', $app);
         
         app()['request'] = function ($c) {
               return new Request('cli', 'cli');
         };
         
         (new ServiceProvider())->boot();
         
         Log::debug('debug log');
         Log::info('info log');
         Log::notice('notice log');
         Log::error('error log');
         Log::warning('warring log');