Laravel项目创建问题

时间:2016-11-02 05:57:15

标签: php laravel ubuntu

当我创建一个laravel项目时,作曲家的一切都很顺利。但是,当我尝试访问默认的index.php页面时,我收到500错误。检查日志后,我发现这是Laravels源代码中的语法错误。我发现变量前面是'......'。

  

[Wed Nov 02 01:47:45.658110 2016] [:error] [pid 4561] [客户   70.66.236.55:55751] PHP解析错误:语法错误,意外'。',期待'&'或变量(T_VARIABLE)in   /var/www/html/proj-dir/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php   在第475行

修好后会弹出一个新的。这又重复了几次。不确定他们是否应该在那里,但我认为'... $ args'不是一个有效的语法(即使对于laravel)

在“修复”所有错误后,我会在浏览器中收到实际的错误消息!

`

>     ErrorException in Gate.php line 132:
>     Missing argument 2 for Illuminate\Auth\Access\Gate::policy(), called in
> /var/www/html/proj-dir/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php
> on line 237 and defined
>     1. in Gate.php line 132
>     2. at HandleExceptions->handleError('2', 'Missing argument 2 for Illuminate\Auth\Access\Gate::policy(), called in
> /var/www/html/proj-dir/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php
> on line 237 and defined',
> '/var/www/html/proj-dir/vendor/laravel/framework/src/Illuminate/Auth/Access/Gate.php',
> '132', array('class' => array('App\Model',
> 'App\Policies\ModelPolicy'), 'this' => object(Gate))) in Gate.php line
> 132
>     3. at Gate->policy(array('App\Model', 'App\Policies\ModelPolicy')) in Facade.php line 237
>     4. at Facade::__callStatic('policy', array('App\Model', 'App\Policies\ModelPolicy')) in AuthServiceProvider.php line 25
>     5. at Gate::policy('App\Model', 'App\Policies\ModelPolicy') in AuthServiceProvider.php line 25
>     6. at AuthServiceProvider->registerPolicies() in AuthServiceProvider.php line 26
>     7. at AuthServiceProvider->boot()
>     8. at call_user_func_array(array(object(AuthServiceProvider), 'boot'), array()) in Container.php line 508
>     9. at Container->call(array(object(AuthServiceProvider), 'boot')) in Application.php line 769
>     10. at Application->bootProvider(object(AuthServiceProvider)) in Application.php line 752
>     11. at Application->Illuminate\Foundation\{closure}(object(AuthServiceProvider),
> '13')
>     12. at array_walk(array(object(EventServiceProvider), object(RoutingServiceProvider), object(AuthServiceProvider),
> object(CookieServiceProvider), object(DatabaseServiceProvider),
> object(EncryptionServiceProvider), object(FilesystemServiceProvider),
> object(FoundationServiceProvider),
> object(NotificationServiceProvider),
> object(PaginationServiceProvider), object(SessionServiceProvider),
> object(ViewServiceProvider), object(AppServiceProvider),
> object(AuthServiceProvider), object(EventServiceProvider),
> object(RouteServiceProvider)), object(Closure)) in Application.php
> line 753
>     13. at Application->boot() in BootProviders.php line 17
>     14. at BootProviders->bootstrap(object(Application)) in Application.php line 203
>     15. at Application->bootstrapWith(array('Illuminate\Foundation\Bootstrap\DetectEnvironment',
> 'Illuminate\Foundation\Bootstrap\LoadConfiguration',
> 'Illuminate\Foundation\Bootstrap\ConfigureLogging',
> 'Illuminate\Foundation\Bootstrap\HandleExceptions',
> 'Illuminate\Foundation\Bootstrap\RegisterFacades',
> 'Illuminate\Foundation\Bootstrap\RegisterProviders',
> 'Illuminate\Foundation\Bootstrap\BootProviders')) in Kernel.php line
> 253
>     16. at Kernel->bootstrap() in Kernel.php line 144
>     17. at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
>     18. at Kernel->handle(object(Request)) in index.php line 54

`

我尝试过多次重建项目,但总是在同一个地方。不确定如何继续。

1 个答案:

答案 0 :(得分:4)

仅供参考,这些都没有语法错误。很可能你正在使用旧版本的PHP。确保您的服务器符合以下要求:

  

PHP> = 5.6.4

     

OpenSSL PHP扩展

     

PDO PHP扩展

     

Mbstring PHP扩展

     

Tokenizer PHP扩展

     

XML PHP扩展

也不要忘记为存储,bootstraps等目录提供必要的权限。

  

安装Laravel后,您可能需要配置一些权限。   存储 bootstrap / cache 目录中的目录   您的网络服务器应该可写,否则Laravel将无法运行。如果你   正在使用Homestead虚拟机,这些权限应该   已经确定了。

在这里,您可以快速找到启动和运行laravel项目所需的一切。

https://laravel.com/docs/5.3