Reputation: 6269
Routes.php
<?php
Route::get('/user/register', 'RegistrationController@registerUser');
//Route::get('/index', 'HomeController@index');
Route::get('/', 'RegistrationController@registration');
?>
RegistrationController.php
<?php namespace App\Http\Controllers;
class RegistrationController extends controller{
public function registration(){
return view('index');
}
public function registerUser(){
var_dump(1212);
die;
}
}
The route root("/") correctly renders my page.
However when I try "/user/register" => I expected to get a dump of 1212 and blank screen. Here is what I got.
How can I fix this problem ?
Best regards, Manish
Upvotes: 0
Views: 72
Reputation: 2284
To do php artisan serve
you must be in your project folder. php artisan serve meant to be used with PHP's internal web server which was introduced in PHP 5.4.
You can optionally specify the port
with
php artisan serve --port=8080
You can optionally specify the host
by doing something like:
php artisan serve --host=local.dev
Here local.dev mean use your ip address like
php artisan serve --host=192.168.0.4
After running this command you can browse by doing something like :
http://localhost:8080/user/register
To get more information about the artisan
command you can do like this
php artisan serve --help
Upvotes: 2
Reputation: 6361
The best practice to use laravel either on server or on localhost is to point your host root to public folder to do it in Xampp open httpd.conf file located under apache/conf folder and change the DocumentRoot to your/laravel/installation/directory/public or you may create a new virtual host here by copy and pasting the default code.
Also make sure that you have .htaccess file in the root of your laravel installation directory with following contents :
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
restart apache and you can surf your laravel host by just visiting localhost:85/lodglify/user/registration
Upvotes: 0
Reputation: 808
just use
Route::get('user/register', 'RegistrationController@registerUser');
Upvotes: 2