命名空间声明语句错误

时间:2018-06-13 08:40:30

标签: laravel-5.2

我尝试使用它来创建我的网站表单,但它可以显示名称空间声明错误。

错误:命名空间声明语句必须是第一个语句或脚本中的任何声明调用之后

  

FatalErrorException:                   C:\ wamp64 \ www \ l52 \ vendor \ illuminate \ html \ HtmlServiceProvider.php line   2:

HtmlServiceProvieder.php

         <?php 
        namespace Illuminate\Html;

        use Illuminate\Support\ServiceProvider;

        class HtmlServiceProvider extends ServiceProvider {

            /**
             * Indicates if loading of the provider is deferred.
             *
             * @var bool
             */
            protected $defer = true;

            /**
             * Register the service provider.
             *
             * @return void
             */
            public function register()
            {
                $this->registerHtmlBuilder();

                $this->registerFormBuilder();

                $this->app->alias('html', 'Illuminate\Html\HtmlBuilder');
                $this->app->alias('form', 'Illuminate\Html\FormBuilder');
            }

            /**
             * Register the HTML builder instance.
             *
             * @return void
             */
            protected function registerHtmlBuilder()
            {
                $this->app->singleton('html', function($app)
                {
                    return new HtmlBuilder($app['url']);
                });
            }

            /**
             * Register the form builder instance.
             *
             * @return void
             */
            protected function registerFormBuilder()
            {
                $this->app->singleton('form', function($app)
                {
                    $form = new FormBuilder($app['html'], $app['url'], $app['session.store']->getToken());

                    return $form->setSessionStore($app['session.store']);
                });
            }

            /**
             * Get the services provided by the provider.
             *
             * @return array
             */
            public function provides()
            {
                return array('html', 'form');
            }

        }
   ?>

作曲家需要&#34;照亮/ html&#34;:&#34; 5. *&#34;

        Open config/app.php and update as follows:

        'providers' => [
           ...
           Illuminate\Html\HtmlServiceProvider::class,
        ],

        'aliases' => [
             ...

            'Form'=> Illuminate\Html\FormFacade::class, 
            'Html'=> Illuminate\Html\HtmlFacade::class,
        ],

0 个答案:

没有答案