调用未定义函数 get():作曲家

Posted

技术标签:

【中文标题】调用未定义函数 get():作曲家【英文标题】:Call to undefined function get(): Composer 【发布时间】:2017-10-22 01:36:45 【问题描述】:

我已经下载了 peak,对其进行配置并推送到我的 vps 服务器中。当我执行“作曲家更新”时,它会显示以下消息:

Illuminate\Foundation\ComposerScripts::postUpdate php artisan optimize PHP 致命错误:在第 3 行的 /var/www/html/app/Http/routes.php 中调用未定义函数 get()

[Symfony\Component\Debug\Exception\FatalErrorException] 调用 未定义函数 get()

脚本 php artisan 优化处理 post-update-cmd 事件 返回错误代码 255

这是我的 EventServiceProvider 和 RouteServiceProvider:

 <?php

 namespace App\Providers;

 use Illuminate\Contracts\Events\Dispatcher as DispatcherContract; use
 Illuminate\Foundation\Support\Providers\EventServiceProvider as
 ServiceProvider;

 class EventServiceProvider extends ServiceProvider 
     /**
      * The event listener mappings for the application.
      *
      * @var array
      */
     protected $listen = [
         'new.game' => [
             'App\Handlers\Events\NewGameHandler',
         ],
     ];

     /**
      * Register any other events for your application.
      *
      * @param  \Illuminate\Contracts\Events\Dispatcher  $events
      * @return void
      */ public function boot()
     
         parent::boot();
     


 <?php

 namespace App\Providers;

 use Illuminate\Routing\Router; use
 Illuminate\Foundation\Support\Providers\RouteServiceProvider as
 ServiceProvider;

 class RouteServiceProvider extends ServiceProvider 
     /**
      * This namespace is applied to the controller routes in your routes file.
      *
      * In addition, it is set as the URL generator's root namespace.
      *
      * @var string
      */
     protected $namespace = 'App\Http\Controllers';

     /**
      * Define your route model bindings, pattern filters, etc.
      *
      * @param  \Illuminate\Routing\Router  $router
      * @return void
      */ public function boot()
     
         parent::boot();
     

     /**
      * Define the routes for the application.
      *
      * @param  \Illuminate\Routing\Router  $router
      * @return void
      */
     public function map(Router $router)
     
         $router->group(['namespace' => $this->namespace], function ($router) 
             require app_path('Http/routes.php');
         );
     

如何使用 artisan 安装此网站?

【问题讨论】:

可读性对于在 *** 上获得帮助大有帮助。我强烈推荐阅读markdown帮助here,并在未来专注于创建具有正确语法的完整句子 你能发布你的 routes.php 文件吗? Frankerz 我来自波兰,我不知道所有特定的 php 语言...我写的很简单,我想要太简单的帮助..这就是我所需要的。我使用选项搜索,所有线程都无法帮助我解决我的错误。 routes.php 在回答线程中。 【参考方案1】:

这是我的 routes.php

    get('/login', ['as' => 'login', 'uses' => 'SteamController@login']);
    get('/', ['as' => 'index', 'uses' => 'GameController@currentGame']);
    get('/about', ['as' => 'about', 'uses' => 'PagesController@about']);
    get('/history', ['as' => 'history', 'uses' => 'PagesController@history']);
    get('/store', ['as' => 'store', 'uses' => 'PagesController@store']);
    get('/top', ['as' => 'top', 'uses' => 'PagesController@top']);
    get('/game/game', ['as' => 'game', 'uses' => 'PagesController@game']);
    get('/loot/loot', ['as' => 'loot', 'uses' => 'LootController@lootgame']);
    get('/donate', 'DonateController@GDonateDonate');
    post('ajax', ['as' => 'ajax', 'uses' => 'AjaxController@parseAction']);
    get('/chat', ['as' => 'chat', 'uses' => 'ChatController@getchat']);
    get('/pay', ['as' => 'pay', 'uses' => 'PagesController@pay']);
    get('/statuspay', ['as' => 'statuspay', 'uses' => 'PagesController@statuspay']);
    get('/fail', ['as' => 'fail', 'uses' => 'PagesController@fail']);
    get('/loot', ['as' => 'loot', 'uses' => 'LootController@listloot']);
    get('/newloot', ['as' => 'newloot', 'uses' => 'LootController@newloot']);
    post('/online', 'online@onlineadd');
    get('/get_giveaway_users', ['as' => 'get_giveaway_users', 'uses' => 'GiveawayController@get_giveaway_users']);
    get('/get_giveaway_count', ['as' => 'get_giveaway_count', 'uses' => 'GiveawayController@get_giveaway_count']);
    get('/giveaway', ['as' => 'giveaway', 'uses' => 'PagesController@giveaway']);
    get('/loothistory', ['as' => 'loot.historyloot', 'uses' => 'LootController@historyloots']);
    get('/testim', ['as' => 'addplaceloot', 'uses' => 'LootController@addplaceloot']);
    get('/testim2', ['as' => 'addplaceloot', 'uses' => 'LootController@newloot']);
    get('/getloot/loot', ['as' => 'getloot', 'uses' => 'LootController@getloot']);
    //get('/resetloottest', ['as' => 'resetloottest', 'uses' => 'LootController@resetloottest']);
    get('/getlootuser/loot', ['as' => 'getlootuser', 'uses' => 'LootController@getlootuser']);

Route::group(['middleware' => 'auth'], function () 
    post('/addplaceloot', ['as' => 'addplaceloot', 'uses' => 'LootController@addplaceloot']);
    get('/myloothistory', ['as' => 'loot.myhistoryloot', 'uses' => 'LootController@myhistoryloots']); 
    get('/deposit', ['as' => 'deposit', 'uses' => 'GameController@deposit']);
    get('/deposit_client', ['as' => 'deposit_client', 'uses' => 'GameController@deposit_client']);
    get('/profile/user', ['as' => 'profile', 'uses' => 'PagesController@user']);
    get('/settings', ['as' => 'settings', 'uses' => 'PagesController@settings']);
    post('/settings/save', ['as' => 'settings.update', 'uses' => 'SteamController@updateSettings']);
    post('/add_message', ['as' => 'chat', 'uses' => 'ChatController@add_message']);
    post('/delete_message', ['as' => 'chat', 'uses' => 'ChatController@delete_message']);
    post('/ban_user', ['as' => 'chat', 'uses' => 'ChatController@ban_user']);
    get('/winner', ['as' => 'admin', 'uses' => 'admin@winner', 'middleware' => 'access:admin']);
    get('/givemoney', ['as' => 'admin', 'uses' => 'admin@givemoney', 'middleware' => 'access:admin']);
    get('/myhistory', ['as' => 'myhistory', 'uses' => 'PagesController@myhistory']);
    get('/myinventory', ['as' => 'myinventory', 'uses' => 'PagesController@myinventory']);
    post('/myinventory', ['as' => 'myinventory', 'uses' => 'PagesController@myinventory']);
    post('/shop/buy', ['as' => 'shop.buy', 'uses' => 'ShopController@buyItem']);
    get('/shop', ['as' => 'shop', 'uses' => 'ShopController@index']);
    get('/shop/history', ['as' => 'shop.history', 'uses' => 'ShopController@history']);
    get('/shop/admin', ['as' => 'shop.admin', 'uses' => 'ShopController@admin', 'middleware' => 'access:admin']);
    get('/logout', ['as' => 'logout', 'uses' => 'SteamController@logout']);
    post('/addTicket', ['as' => 'add.ticket', 'uses' => 'GameController@addTicket']);
    post('/getBalance', ['as' => 'get.balance', 'uses' => 'GameController@getBalance']);
    get('/api/addusers', ['as' => 'addusers', 'uses' => 'GiveawayController@addusers']);
    get('/support', ['as' => 'support.index', 'uses' => 'SupportController@support']);
    get('/support/ticket', ['as' => 'ticket', 'uses' => 'SupportController@ticket']);
);

Route::group(['prefix' => 'api', 'middleware' => 'secretKey'], function () 
    //get('/newBet', 'GameController@newBet');
    get('/online', 'online@online');
    get('/lastwinner', 'GameController@lastwinner');
    get('/checkOffer', 'GameController@checkOffer');
    get('/newBet', 'GameController@newBet');
    post('/setGameStatus', 'GameController@setGameStatus');
    post('/setPrizeStatus', 'GameController@setPrizeStatus');
    post('/getCurrentGame', 'GameController@getCurrentGame');
    post('/haventescrow', 'GameController@haventescrow');
    post('/getWinners', 'GameController@getWinners');
    post('/getPreviousWinner', 'GameController@getPreviousWinner');
    post('/newGame', 'GameController@newGame');
    get('/shop/newItems', 'ShopController@addItemsToSale');
    post('/shop/setItemStatus', 'ShopController@setItemStatus');
    get('/loot/newItems', 'LootController@newloot');
    post('/loot/setItemStatus', 'LootController@setLootStatus');
);

【讨论】:

可以用 Route::get() 代替 get() 吗? 在哪里??在 RouteServiceProvider 中? 在答案中发布示例 检查我的新答案【参考方案2】:

代替

Route::group(['middleware' => 'auth'], function () 
    post('/addplaceloot', ['as' => 'addplaceloot', 'uses' => 'LootController@addplaceloot']);
    get('/myloothistory', ['as' => 'loot.myhistoryloot', 'uses' => 'LootController@myhistoryloots']); 
    get('/deposit', ['as' => 'deposit', 'uses' => 'GameController@deposit']);
);

试试

Route::group(['middleware' => 'auth'], function () 
    Route::post('/addplaceloot', ['as' => 'addplaceloot', 'uses' => 'LootController@addplaceloot']);
    Route::get('/myloothistory', ['as' => 'loot.myhistoryloot', 'uses' => 'LootController@myhistoryloots']); 
    Route::get('/deposit', ['as' => 'deposit', 'uses' => 'GameController@deposit']);
);

【讨论】:

routes.php 中的每个地方都将 get() 更改为 Route::get() ??

以上是关于调用未定义函数 get():作曲家的主要内容,如果未能解决你的问题,请参考以下文章

php artisan:调用未定义函数 App\Http\Services\mcrypt_get_block_size()

如何在 PHP 中解决“调用未定义函数 Composer\Json\json_decode()”?

Laravel 刀片模板不起作用 - 调用未定义的函数 Illuminate\View\Compilers\token_get_all()

wordpress 插件 -> 调用未定义的函数 wp_get_current_user()

Lumen 5.3 未定义变量:闭包

致命错误:在第 2 行的 index.php 中调用未定义函数 get_header()