2016-11-02 102 views
1

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

[Wed Nov 02 01:47:45.658110 2016] [:error] [pid 4561] [client 70.66.236.55:55751] PHP Parse error: syntax error, unexpected '.', expecting '&' or variable (T_VARIABLE) in /var/www/html/proj-dir/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 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 

`

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

+0

请在此处插入您的代码,您发现错误。 –

+0

您需要PHP 5.6.x来支持该功能。 – Marty

+0

下载最新的xampp,然后再试一次。 –

回答

4

仅供参考这些不是语法错误。很可能你使用的是旧版本的PHP。确保您的服务器满足下列要求:

PHP >= 5.6.4

OpenSSL PHP Extension

PDO PHP Extension

Mbstring PHP Extension

Tokenizer PHP Extension

XML PHP Extension

也不要忘了给权限像存储,引导程序目录。

After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run. If you are using the Homestead virtual machine, these permissions should already be set.

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

https://laravel.com/docs/5.3

+0

我安装了多个版本的php。未安装所有这些,然后重新安装5.6,它的工作 – DrProfesor