2016-11-02 98 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