在laravel外面照亮包裹

时间:2015-07-09 07:43:10

标签: laravel laravel-5 illuminate-container

我是Laravel的新手,我在Laravel之外使用了几乎所有的L5套装。但是我有一些问题要做这些工作。

这是我的composer.json文件:

{
      "require": {
         "slim/slim": "2.*",
         "zeuxisoo/slim-whoops": "0.2.0",
         "filp/whoops": "1.1.2",

         "illuminate/database": "5.1.*",
         "illuminate/support": "5.1.*",
         "illuminate/session": "5.1.*",
         "illuminate/filesystem": "5.1.*",
         "illuminate/config": "5.1.*",
         "illuminate/session": "5.1.*",
         "illuminate/routing": "^5.1",
         "illuminate/events": "5.1.*",
         "illuminate/translation": "5.1.*",
         "illuminate/encryption": "5.1.*",
         "illuminate/queue": "5.1.*",
         "illuminate/mail": "5.1.*",
         "illuminate/view": "5.1.*",

         "laravelcollective/html": "5.1.*",

         "iron-io/iron_mq": "~2.0",
         "Mockery/Mockery": "~0.9.1",
         "pimple/pimple": "3.0",

         "philo/laravel-blade": "3.*",
         "jenssegers/mongodb": "^2.1",

         "illuminate/auth": "5.1.*",
         "illuminate/bus": "5.1.*",
         "illuminate/broadcasting": "5.1.*",
         "illuminate/cache": "5.1.*",
         "illuminate/console": "5.1.*", 
         "illuminate/container": "5.1.*",
         "illuminate/contracts": "5.1.*",
         "illuminate/cookie": "5.1.*",
         "illuminate/hashing": "5.1.*",
         "illuminate/http": "5.1.*",
         "illuminate/log": "5.1.*",
         "illuminate/pagination": "5.1.*",
         "illuminate/pipeline": "5.1.*",
         "illuminate/redis": "5.1.*",
         "illuminate/validation": "5.1.*"

},
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        }
    }
}

那就是index.php:

    // Import Illuminate packages
    require_once '../../../vendor/autoload.php';

    // set database connection and setup
    require_once '../../../config/bootstrap.php';

    use Illuminate\Support\Facades\Response as Response;

    // Instantiate the container
    $app = new Illuminate\Container\Container();

    // Tell facade about the application instance
    Illuminate\Support\Facades\Facade::setFacadeApplication($app);

    // register application instance with container
    $app['app'] = $app;

    // set environment 
    $app['env'] = 'production';

    $app->instance('request', \Illuminate\Http\Request::capture());

    // Register service providers

    with(new Illuminate\Events\EventServiceProvider($app))->register();
    with(new Illuminate\Routing\RoutingServiceProvider($app))->register();

    with(new Illuminate\Auth\AuthServiceProvider($app))->register();
    with(new Illuminate\Broadcasting\BroadcastServiceProvider($app))->register();
    with(new Illuminate\Bus\BusServiceProvider($app))->register();
    with(new Illuminate\Cache\CacheServiceProvider($app))->register();

    with(new Illuminate\Routing\ControllerServiceProvider($app))->register();
    with(new Illuminate\Cookie\CookieServiceProvider($app))->register();
    with(new Illuminate\Database\DatabaseServiceProvider($app))->register();
    with(new Illuminate\Encryption\EncryptionServiceProvider($app))->register();
    with(new Illuminate\Filesystem\FilesystemServiceProvider($app))->register();

    with(new Illuminate\Hashing\HashServiceProvider($app))->register();
    with(new Illuminate\Mail\MailServiceProvider($app))->register();
    with(new Illuminate\Pagination\PaginationServiceProvider($app))->register();
    with(new Illuminate\Pipeline\PipelineServiceProvider($app))->register();
    with(new Illuminate\Queue\QueueServiceProvider($app))->register();
    with(new Illuminate\Redis\RedisServiceProvider($app))->register();
    with(new Illuminate\Auth\Passwords\PasswordResetServiceProvider($app))->register();
    with(new Illuminate\Session\SessionServiceProvider($app))->register();
    with(new Illuminate\Translation\TranslationServiceProvider($app))->register();
    with(new Illuminate\Validation\ValidationServiceProvider($app))->register();
    with(new Illuminate\View\ViewServiceProvider($app))->register();

    with(new Collective\Html\HtmlServiceProvider($app))->register();

    // Class aliases
    class_alias('Collective\Html\FormFacade', 'Form');
    class_alias('Collective\Html\HtmlFacade', 'Html');

    // Include all the routes
    $app['router']->get('/', 'TestController@index');

    $app['router']->get('/view', 'TestController@show');

    $app['router']->get('/{id}', 'TestController@create');

    // Instantiate the request
    $request = Illuminate\Http\Request::createFromGlobals();

    // Dispatch the router
    $response = $app['router']->dispatch($request);

    // Send the response
    $response->send();

和TestController类:

<?php

use Illuminate\Routing\Controller as Controller;
use Illuminate\Support\Facades\DB as DB;
use Illuminate\Support\Facades\View as View;


class TestController extends Controller {

   public function show() {
        return View::make('hello2');
   }
}

当我调用TestController的show方法时,我收到此错误:

  

[致命错误]未捕获的异常&#39; ReflectionException&#39;与消息   &#39;班级配置不存在&#39;在   /var/www/html/vendor/illuminate/container/Container.php:736

我不知道如何使用配置包,我认为这就是我收到此错误的原因。配置包没有服务提供者,所以我无法启动它。

我尝试在laravel之外使用照明包因为我在第三方自定义php框架上,并且工作是在L5中逐渐迁移有几个原因。如果这是最好的做法,我想要你的经验。

0 个答案:

没有答案