Невозможно получить доступ к URL-адресу в маршрутах Laravel

Я изучаю Laravel прямо сейчас, и я делаю это, создавая простой CRUD (CREATE-READ-UPDATE-DELETE). Это мой способ изучения новой структуры. Прежде чем я использую CodeIgniter, но я узнал, что Laravel намного лучше, чем CodeIgniter, и у него много функций.

Я следую этому руководству

http://www.allshorevirtualstaffing.com/developing-crud-applications-in-laravel-4/

И я показываю представление CREATE. Но я не могу получить доступ к его маршрутам.

Это моя структура папок

wamp www mylaravel app bootstrap public vendor 

Пока у меня есть эти коды:

контроллер

 <?php class EmployeesController extends \BaseController { /** * Display a listing of the resource. * * @return Response */ public function index() { $employees = Employee::all(); return View::make('index', compact('employees')); } /** * Show the form for creating a new resource. * * @return Response */ public function create() { return View::make('create'); } /** * Store a newly created resource in storage. * * @return Response */ public function store() { // } /** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { // } /** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { // } /** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { // } /** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // } public function handleCreate() { $employee = new Employee; $employee->first_name = Input::get('first_name'); $employee->last_name = Input::get('last_name'); $employee->email = Input::get('email'); $employee->save(); return Redirect::action('EmployeesController@index'); } } 

Модель

 <?php class Employee extends Eloquent { } ?> 

VIEW (index.blade.php)

 @extends('layout') @section('content') <div class="page-header" style="border: 1x solid #0077b3; text-align-center"> <h1>EMS <small> Better Employee Management </small> </h1> </p></div> <div class="panel panel-default"> <div class="panel-body"> <a href="{{ action('EmployeesController@create') }}" class="btn btn-info">Add new employee</a> </div> @if ($employees->isEmpty()) There are no employees! :( @else <table class="table table-striped"> <thead> <tr> <th>First Name</th> <th>Last Name</th> <th>Email</th> <th>Actions</th> </tr> </thead> <tbody> @foreach($employees as $employee) <tr> <td> {{ $employee->first_name }} </td> <td> {{ $employee->last_name }} </td> <td> {{ $employee->email }} </td> <td> <a href="{{ action('EmployeesController@edit', $employee->id) }}" class="btn btn-default">Edit</a> <a href="{{ action('EmployeesController@delete', $employee->id) }}" class="btn btn-danger">Delete</a> </td> </tr> @endforeach </tbody> </table> @endif @stop </div> </div> - @extends('layout') @section('content') <div class="page-header" style="border: 1x solid #0077b3; text-align-center"> <h1>EMS <small> Better Employee Management </small> </h1> </p></div> <div class="panel panel-default"> <div class="panel-body"> <a href="{{ action('EmployeesController@create') }}" class="btn btn-info">Add new employee</a> </div> @if ($employees->isEmpty()) There are no employees! :( @else <table class="table table-striped"> <thead> <tr> <th>First Name</th> <th>Last Name</th> <th>Email</th> <th>Actions</th> </tr> </thead> <tbody> @foreach($employees as $employee) <tr> <td> {{ $employee->first_name }} </td> <td> {{ $employee->last_name }} </td> <td> {{ $employee->email }} </td> <td> <a href="{{ action('EmployeesController@edit', $employee->id) }}" class="btn btn-default">Edit</a> <a href="{{ action('EmployeesController@delete', $employee->id) }}" class="btn btn-danger">Delete</a> </td> </tr> @endforeach </tbody> </table> @endif @stop </div> </div> 

VIEW (layout.blade.php)

 <!DOCTYPE html> <html> <head> <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet"> <style type="text/css"> table form { margin-bottom: 0; } form ul { margin-left: 0; list-style: none; } .error { color: red; font-style: italic; } body { padding-top: 20px; } </style> </head> <body> <div class="container"> @if (Session::has('message')) <div class="flash alert"> <p>{{ Session::get('message') }}</p> </div> @endif @yield('content') </div> </body> </html> 

VIEW (create.blade.php)

 @extends('layout') @section('content') <div class="page-header" style="border: 1px solid #0077b3;"> <h1>Add New Employee</h1> @if( $errors->count() > 0 ) <div class="alert alert-danger"> <ul> @foreach( $errors->all() as $message)</p> <li>{{ $message }}</li> @endforeach </ul> </div> @endif <form action="{{ action('EmployeesController@handleCreate') }}" method="post" role="form"> <div class="form-group"> <label for="first_name">First Name</label> <input type="text" class="form-control" name="first_name" /> </div> <div class="form-group"> <label for="last_name">Last Name</label> <input type="text" class="form-control" name="last_name" /> </div> <div class="form-group"> <label for="email">Last Name</label> <input type="text" class="form-control" name="email" /> </div> <input type="submit" value="Add" class="btn btn-primary" /> <a href=" action('EmployeesController@index') " class="btn btn-link">Cancel</a> </form> @stop </div> 

МАРШРУТЫ (routes.php)

 <?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the Closure to execute when that URI is requested. | */ /* Route::get('/', function() { return View::make('hello'); }); */ Route::model('employee', 'Employee'); Route::get('/', 'EmployeesController@index'); Route::get('/create', 'EmployeesController@create'); Route::get('/edit/{$employee}', 'EmployeesController@edit'); Route::get('/delete/{$employee}', 'EmployeesController@delete'); Route::post('/create', 'EmployeesController@handleCreate'); Route::post('/edit', 'EmployeesController@handleEdit'); Route::post('/delete', 'EmployeesController@handleDelete'); 

Когда я получаю доступ к этому URL-адресу:

 http://localhost/mylaravel/public/ 

Он отображает страницу индекса с таблицей сотрудников

Но когда я нажимаю ADD NEW EMPLOYEE

Перейти на эту страницу

 http://localhost/mylaravel/public/create 

И у меня есть эта ошибка:

 Not Found The requested URL /mylaravel/public/create was not found on this server. Apache/2.4.9 (Win64) OpenSSL/1.0.1g PHP/5.5.12 Server at localhost Port 80 

Я не знаю, где я ошибся. ты можешь помочь мне с этим?

Вы должны включить mod_rewrite в свой конфигурационный файл Apache – в строке httpd.conf :

 LoadModule rewrite_module modules/mod_rewrite.so 

должно быть без # в начале. После изменения вы должны перезапустить сервер.

Вы также должны иметь в public каталоге файл по умолчанию .htaccess из Laravel – я упоминаю об этом, потому что на веб-серверах иногда .htaccess файлы скрыты, и если вы копируете проект с FTP, вы не можете их скопировать.