![](/style/images/good.png)
![](/style/images/bad.png)
Laravel - Controllers without routing
source link: https://www.codesd.com/item/laravel-controllers-without-routing.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Laravel - Controllers without routing
I am newbie to laravel. I created new controller - book. This is my code -
class BookController extends BaseController {
public function index()
{
return View::make('book.index');
}
public function insert()
{
return View::make('book.insert');
}
}
My routes.php -
Route::get('book/', 'BookController@index');
//Route::any('book/insert', array('uses' => 'BookController@insert'));
When i uncomment 2nd line, i can access insert page. Is it possible to access pages without add them to routes.
Now it produce this error
![QL3M7.png](https://i.stack.imgur.com/QL3M7.png)
You may read about resource controller.
Execute this on terminal:
php artisan controller:make BookController
This command will generate BookController.php
in your app/controllers
folder. Read the code for more information.
Define in your routes.php
file:
Route::resource('book', 'BookController');
Actions Handled By Resource Controller:
![rVk0F.png](https://i.stack.imgur.com/rVk0F.png)
Related Articles
Test controllers without routing
Laravel 5.1 - Routes Error - NotFoundHttpException in RouteCollection.php line 143:
Route planning without Route :: controller
Laravel Forms without using a blade
Communicating between Controllers without Events
How do I add common actions to controllers without using inheritance?
Is it possible to do TCP / IP between PCs without router
Angularjs: routes and controllers without templateURLs?
Laravel 5.3 Route :: resource without REST
Laravel Creating dynamic routes to controllers from the Mysql database
Can you pass parameters to controllers via routes.rb without appearing in the URL?
How to link to an action without route help
Laravel 5.4 routing for the same prefix group, but a different middleware giving an error
Laravel 5.1 route error message
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK