src/Core/Console/ConsoleHelper.php
public static function executePackage(
        $package,
        $task,
        Request $request,
        $config = [],
        $appClass = 'Windwalker\Web\Application'
    ) {
        $profile = Ioc::getProfile();

        Ioc::setProfile('web');

        if (!class_exists($appClass)) {
            throw new \LogicException($appClass . ' not found, you have to provide an exists Application class name.');
        }

        if (!is_subclass_of($appClass, WebApplication::class)) {
            throw new \LogicException('Application class should be sub class of ' . WebApplication::class);
        }

        /** @var WebApplication $app */
        $app = new $appClass($request);
        $app->boot();
        $app->getRouter();

        $package = $app->getPackage($package);

        $container = $app->getContainer();

        $container->share('current.package', $package);
        $container->get('config')->load($config);

        $response = $package->execute($task, $request, new \Windwalker\Http\Response\Response());

        Ioc::setProfile($profile);

        return $response;
    }
public static function executePackage(
        $package,
        $task,
        Request $request,
        $config = [],
        $appClass = 'Windwalker\Web\Application'
    ) {
        $profile = Ioc::getProfile();

        Ioc::setProfile('web');

        if (!class_exists($appClass)) {
            throw new \LogicException($appClass . ' not found, you have to provide an exists Application class name.');
        }

        if (!is_subclass_of($appClass, WebApplication::class)) {
            throw new \LogicException('Application class should be sub class of ' . WebApplication::class);
        }

        /** @var WebApplication $app */
        $app = new $appClass($request);
        $app->boot();
        $app->getRouter();

        $package = $app->getPackage($package);

        $container = $app->getContainer();

        $container->share('current.package', $package);
        $container->get('config')->load($config);

        $response = $package->execute($task, $request, new \Windwalker\Http\Response\Response());

        Ioc::setProfile($profile);

        return $response;
    }
public static function executePackage ( $ package , $ task , Request $ request , $ config = [ ] , $ appClass = 'Windwalker\Web\Application' ) { $ profile = Ioc :: getProfile ( ) ; Ioc :: setProfile ( 'web' ) ; if ( ! class_exists ( $ appClass ) ) { throw new \ LogicException ( $ appClass . ' not found, you have to provide an exists Application class name.' ) ; } if ( ! is_subclass_of ( $ appClass , WebApplication :: class ) ) { throw new \ LogicException ( 'Application class should be sub class of ' . WebApplication :: class ) ; } /** @var WebApplication $app */ $ app = new $ appClass ( $ request ) ; $ app -> boot ( ) ; $ app -> getRouter ( ) ; $ package = $ app -> getPackage ( $ package ) ; $ container = $ app -> getContainer ( ) ; $ container -> share ( 'current.package' , $ package ) ; $ container -> get ( 'config' ) -> load ( $ config ) ; $ response = $ package -> execute ( $ task , $ request , new \ Windwalker \ Http \ Response \ Response ( ) ) ; Ioc :: setProfile ( $ profile ) ; return $ response ; }
Execute a package in CLI environment.

@param string  $package
@param string  $task
@param Request $request
@param array   $config
@param string  $appClass

@return Response
@throws \ReflectionException
@throws \Windwalker\DI\Exception\DependencyResolutionException
Execute a package in CLI environment .