新的Lumen 5.5项目“未定义的变量:应用程序” - php

我是Lumen的新手,只是尝试创建一个应用程序。我在应用程序-> Laravel \ Lumen \ Concerns {closure}(8,'Undefined variable:app','/Users/test/Sites/books/routes/web.php',14,array(当我尝试使用以下代码时,'router'=> object(Router))):

$app->group(['prefix' => 'book/'], function() use ($app) {
    $app->get('/','BooksController@index'); //get all the routes    
    $app->post('/','BooksController@store'); //store single route
    $app->get('/{id}/', 'BooksController@show'); //get single route
    $app->put('/{id}/','BooksController@update'); //update single route
    $app->delete('/{id}/','BooksController@destroy'); //delete single route
});

根据文件https://lumen.laravel.com/docs/5.5/routing,这应该起作用。我正在跟踪在https://paulund.co.uk/creating-a-rest-api-with-lumen处找到的教程,我知道5.5几天前才问世,所以可能还没有人知道答案,但是可以提供任何帮助。

参考方案

似乎有一些未记录的更改。您需要将$app更改为$router,如下所示:

$router->group(['prefix' => 'book/'], function() use ($router) {
    $router->get('/','BooksController@index'); //get all the routes    
    $router->post('/','BooksController@store'); //store single route
    $router->get('/{id}/', 'BooksController@show'); //get single route
    $router->put('/{id}/','BooksController@update'); //update single route
    $router->delete('/{id}/','BooksController@destroy'); //delete single route
});

php-casperjs获取内部文本 - php

我正在为casperjs使用php包装器-https://github.com/alwex/php-casperjs我正在网上自动化一些重复的工作,我需要访问一个项目的innerText,但是我尚不清楚如何从casperjs浏览器访问dom。我认为在js中我会var arr = document.querySelector('label.input…

php:是否有充分的理由引用所有数组键/索引? - php

我正在遍历别人的代码,他们总是避免转义其数组键。例如:$ row_rsCatalogsItems [名称]代替$ row_rsCatalogsItems ['名称']因此,我不断地对自己接触的所有事物进行微小的更改,以应对这些惰性。但是现在我想知道这样做是否有很多好处。我得到它会在默认为字符串之前检查常量(我在处理常量时会讨厌php中的行为,因为即使未定义,…

PayPal PHP IPN示例引用了哪些POST序列化问题? - php

PayPal用于PHP IPN侦听器的示例代码在顶部具有以下注释/代码:// reading posted data from directly from $_POST causes serialization // issues with array data in POST // reading raw POST data from input stre…

PHP标头功能不起作用 - php

我曾经使用此功能从一个PHP页面重定向到另一个:header( 'Location: student.php?cnp='.$_REQUEST['name']) ; 在我的本地主机中,它确实可以工作,但是如果在Internet中对其进行测试,则不会重定向。我也尝试给出完整的路径(如http://.../student.p…

排序PHP迭代器 - php

有没有一种简单的方法可以在PHP中对迭代器进行排序(而不仅仅是将其全部拉入数组并进行排序)。我有一个具体的例子是DirectoryIterator,但是对所有迭代器都有一个通用的解决方案会很好。$dir = new DirectoryIterator('.'); foreach ($dir as $file) echo $file->…