I used the command make:auth and it showed:
Created View: /var/www/myblog/resources/views/auth/login.blade.php
Created View: /var/www/myblog/resources/views/auth/register.blade.php
Created View: /var/www/myblog/resources/views/auth/passwords/email.blade.php
Created View: /var/www/myblog/resources/views/auth/passwords/reset.blade.php
Created View: /var/www/myblog/resources/views/auth/emails/password.blade.php
Created View: /var/www/myblog/resources/views/layouts/app.blade.php
Created View: /var/www/myblog/resources/views/home.blade.php
Created View: /var/www/myblog/resources/views/welcome.blade.php
Installed HomeController.
Updated Routes File.
Authentication scaffolding generated successfully!
It looks like great and I got a homepage showing up correctly.
see picture here
But when I was trying to access Login and Register page, something went wrong.
It gave me errors like:
Not Found
The requested URL /login was not found on this server.
Apache/2.4.7 (Ubuntu) Server at ...
and I typed php artisan route:list in terminal I got this:
+--------+-----------+-------------------------+-----------------+-----------------------------------------------------------------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+-----------+-------------------------+-----------------+-----------------------------------------------------------------+------------+
| | GET|HEAD | / | | Closure | |
| | GET|HEAD | article | article.index | App\Http\Controllers\ArticleController#index | |
| | POST | article | article.store | App\Http\Controllers\ArticleController#store | |
| | GET|HEAD | article/create | article.create | App\Http\Controllers\ArticleController#create | |
| | DELETE | article/{article} | article.destroy | App\Http\Controllers\ArticleController#destroy | |
| | PUT|PATCH | article/{article} | article.update | App\Http\Controllers\ArticleController#update | |
| | GET|HEAD | article/{article} | article.show | App\Http\Controllers\ArticleController#show | |
| | GET|HEAD | article/{article}/edit | article.edit | App\Http\Controllers\ArticleController#edit | |
| | GET|HEAD | home | | App\Http\Controllers\HomeController#index | web,auth |
| | GET|HEAD | login | | App\Http\Controllers\Auth\AuthController#showLoginForm | web,guest |
| | POST | login | | App\Http\Controllers\Auth\AuthController#login | web,guest |
| | GET|HEAD | logout | | App\Http\Controllers\Auth\AuthController#logout | web |
| | POST | password/email | | App\Http\Controllers\Auth\PasswordController#sendResetLinkEmail | web,guest |
| | POST | password/reset | | App\Http\Controllers\Auth\PasswordController#reset | web,guest |
| | GET|HEAD | password/reset/{token?} | | App\Http\Controllers\Auth\PasswordController#showResetForm | web,guest |
| | GET|HEAD | register | | App\Http\Controllers\Auth\AuthController#showRegistrationForm | web,guest |
| | POST | register | | App\Http\Controllers\Auth\AuthController#register | web,guest |
+--------+-----------+-------------------------+-----------------+-----------------------------------------------------------------+------------+
It's a bit different from what I expect. Cuz from what I learned in laracast.com, the route list should be like "Auth\login" instead of merely "login"... Idk what's going wrong here, is it because I'm using apache? or other configurations I didn't set up correctly... Looking for help
Also another question:
when I access www.mydomain.com, I'd expect the default welcome page instead of auth's home page but actually it gives me the auth's home page instead. But when I was trying to access www.mydomain.com/home which I expect to see that home page again, instead I received 404 not found errors which confused me a lot. here is my routes.php:
<?php
/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
return view('welcome');
});
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/
Route::resource('article', 'ArticleController');
Route::group(['middleware' => 'web'], function () {
Route::auth();
Route::get('/home', 'HomeController#index');
});
Hi Guys I just solved this problem.
This problem is definitely unrelated to laravel and is totally caused by Apache2 settings.
What I did is simply
sudo a2enmod rewrite
and restart service.
Related
using laravel 5.7, i have the following code line in routes/web.php
Route::resource('admin/users', 'Admin\AdminUsersController');
when i list routes via : php artisan route:list i get the following:
| | GET|HEAD | admin/users | users.index | App\Http\Controllers\Admin\AdminUsersController#index | web
| | POST | admin/users | users.store | App\Http\Controllers\Admin\AdminUsersController#store | web
| | GET|HEAD | admin/users/create | users.create | App\Http\Controllers\Admin\AdminUsersController#create | web
| | GET|HEAD | admin/users/{user} | users.show | App\Http\Controllers\Admin\AdminUsersController#show | web
| | PUT|PATCH | admin/users/{user} | users.update | App\Http\Controllers\Admin\AdminUsersController#update | web
| | DELETE | admin/users/{user} | users.destroy | App\Http\Controllers\Admin\AdminUsersController#destroy | web
| | GET|HEAD | admin/users/{user}/edit | users.edit | App\Http\Controllers\Admin\AdminUsersController#edit | web
why routes are not named following the directory structure : admin.users.method
Laravel takes the last string after slash in resource routes to decide the route name. You can refer Illuminate/Routing/ResourceRegistrar.php file's register() and prefixedResource() methods.
I am using Laravel 5.4 and I have created a controller with resources. Now I would like to open the edit page in my app like the following:
a href="{{ route('tasks.edit', ['tasks'=>$storedTask->id]) }}" class='btn btn-default'>Edit</a>
In my view I am using:
Route::resource('/', 'IndexController');
However, I get back
Sorry, the page you are looking for could not be found when opening the link.
When looking into my routes list the URIs are emtpy.
+--------+-----------+------------------------+------------------+------------------------------------------------------------------------+--------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+-----------+------------------------+------------------+------------------------------------------------------------------------+--------------+
| | GET|HEAD | / | index | App\Http\Controllers\IndexController#index | web |
| | POST | / | store | App\Http\Controllers\IndexController#store | web |
| | PUT|PATCH | {} | update | App\Http\Controllers\IndexController#update | web |
| | DELETE | {} | destroy | App\Http\Controllers\IndexController#destroy | web |
| | GET|HEAD | {} | show | App\Http\Controllers\IndexController#show | web |
| | GET|HEAD | {}/edit | edit | App\Http\Controllers\IndexController#edit | web |
+--------+-----------+------------------------+------------------+------------------------------------------------------------------------+--------------+
I guess that my model is not "associated" with my controller and therefore the Route::resource view.
Any suggestions how to fix this?
You can't use resource route with just /. Change it to:
Route::resource('tasks', 'IndexController');
this is the first time that I try to migrate a Laravel application from my local environment to my remote server.
So basically I have uploaded the entire content of my local Laravel 5.4 application into this folder of my remote server:
/var/www/html/HotelRegistration
Then I am trying to opening this URL into the browser (my remote server):
http://89.36.211.48/HotelRegistration/public/
and how you can see the standard Laravel homepage appear (it is expected, I yet have to replace this page with a custom one).
The problem is that in my web.xml file I have declared these routes:
Route::get('/', function () {
return view('welcome');
});
Route::get('contact', function() {
return View::make('contact');
});
Route::post('contact', 'EnquiryController#index');
Route::resource('/registration', 'RegistrationController');
The first one is the one related to the standard Laravel page that works fine, the last one is:
Route::resource('/registration', 'RegistrationController');
and it should handle HTTP GET request toward the /registration by the RegistrationController class, this controller class contains this index() method:
/**
* Metodo che mostra la pagina di registrazione di un nuovo utente albergatore.
* #return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(){
Log::info('index() START');
return view('/registration/index');
}
that opening this URL:
http://89.36.211.48/HotelRegistration/public/registration
should show a registration page. But, as you can see opening it I obtain a Not Found error message.
Into the /var/www/html/HotelRegistration/storage/logs/laravel.log file there is nothing, I expected the output of the log putted at the beginning of the previous method controller, so it seems that it doesn't not enter in this method.
The strange thing is that opening the same URL on my localhost system (http://localhost/HotelRegistration/public/registration) it works fine.
I am thinking that maybe it could be a routes problem (maybe some route is missing), if I perform this statment on my local environment:
php artisan route:list
I obtain:
+--------+-----------+----------------------------------+----------------------+------------------------------------------------------+--------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+-----------+----------------------------------+----------------------+------------------------------------------------------+--------------+
| | GET|HEAD | / | | Closure | web |
| | GET|HEAD | activate | | App\Http\Controllers\RegistrationController#activate | web |
| | GET|HEAD | api/user | | Closure | api,auth:api |
| | GET|HEAD | contact | | Closure | web |
| | POST | contact | | App\Http\Controllers\EnquiryController#index | web |
| | GET|HEAD | errors | errors | Closure | web |
| | POST | registration | registration.store | App\Http\Controllers\RegistrationController#store | web |
| | GET|HEAD | registration | registration.index | App\Http\Controllers\RegistrationController#index | web |
| | GET|HEAD | registration/create | registration.create | App\Http\Controllers\RegistrationController#create | web |
| | DELETE | registration/{registration} | registration.destroy | App\Http\Controllers\RegistrationController#destroy | web |
| | PUT|PATCH | registration/{registration} | registration.update | App\Http\Controllers\RegistrationController#update | web |
| | GET|HEAD | registration/{registration} | registration.show | App\Http\Controllers\RegistrationController#show | web |
| | GET|HEAD | registration/{registration}/edit | registration.edit | App\Http\Controllers\RegistrationController#edit | web |
+--------+-----------+----------------------------------+----------------------+------------------------------------------------------+--------------+
that contains this route:
| | GET|HEAD | registration | registration.index | App\Http\Controllers\RegistrationController#index | web |
that should be the route related to the previous index() method of my controller.
But I can found it also performing the same statment on my remote environment:
root#Betrivius-VPS:/var/www/html/HotelRegistration# php artisan route:list
+--------+-----------+----------------------------------+----------------------+------------------------------------------------------+--------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+-----------+----------------------------------+----------------------+------------------------------------------------------+--------------+
| | GET|HEAD | / | | Closure | web |
| | GET|HEAD | activate | | App\Http\Controllers\RegistrationController#activate | web |
| | GET|HEAD | api/user | | Closure | api,auth:api |
| | GET|HEAD | contact | | Closure | web |
| | POST | contact | | App\Http\Controllers\EnquiryController#index | web |
| | GET|HEAD | errors | errors | Closure | web |
| | GET|HEAD | registration | registration.index | App\Http\Controllers\RegistrationController#index | web |
| | POST | registration | registration.store | App\Http\Controllers\RegistrationController#store | web |
| | GET|HEAD | registration/create | registration.create | App\Http\Controllers\RegistrationController#create | web |
| | GET|HEAD | registration/{registration} | registration.show | App\Http\Controllers\RegistrationController#show | web |
| | PUT|PATCH | registration/{registration} | registration.update | App\Http\Controllers\RegistrationController#update | web |
| | DELETE | registration/{registration} | registration.destroy | App\Http\Controllers\RegistrationController#destroy | web |
| | GET|HEAD | registration/{registration}/edit | registration.edit | App\Http\Controllers\RegistrationController#edit | web |
+--------+-----------+----------------------------------+----------------------+------------------------------------------------------+--------------+
So what could be the problem? Why on my remote environment this URL (http://89.36.211.48/HotelRegistration/public/registration) seems not to be hanbdled as done in the local one?
What could be the problem? What am I missing? How can I try to fix it?
You need to first change the permissions and give the requires permission and run this command
composer install
or
composer update
Thank you
I am pretty new to Laravel and I have the following doubt.
If I perform the php artisan route:list statment to obtain the list of all the routes on my Laravel website I obtain this output:
$ php artisan route:list
+--------+-----------+----------------------------------+----------------------+-----------------------------------------------------+--------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+-----------+----------------------------------+----------------------+-----------------------------------------------------+--------------+
| | GET|HEAD | / | | Closure | web |
| | GET|HEAD | api/user | | Closure | api,auth:api |
| | POST | contact | | App\Http\Controllers\EnquiryController#index | web |
| | GET|HEAD | contact | | Closure | web |
| | POST | registration | registration.store | App\Http\Controllers\RegistrationController#store | web |
| | GET|HEAD | registration | registration.index | App\Http\Controllers\RegistrationController#index | web |
| | GET|HEAD | registration/create | registration.create | App\Http\Controllers\RegistrationController#create | web |
| | PUT|PATCH | registration/{registration} | registration.update | App\Http\Controllers\RegistrationController#update | web |
| | GET|HEAD | registration/{registration} | registration.show | App\Http\Controllers\RegistrationController#show | web |
| | DELETE | registration/{registration} | registration.destroy | App\Http\Controllers\RegistrationController#destroy | web |
| | GET|HEAD | registration/{registration}/edit | registration.edit | App\Http\Controllers\RegistrationController#edit | web |
+--------+-----------+----------------------------------+----------------------+-----------------------------------------------------+--------------+
but into the routes/web.php file I only have declared these stuff:
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::get('contact', function() {
return View::make('contact');
});
Route::post('contact', 'EnquiryController#index');
Route::resource('/registration', 'RegistrationController');
So it seems that the number of the effective routes is greater that the routes effectively declared into the routes/web.php file.
Why? Maybe it could depend by this specific definition?
Route::resource('/registration', 'RegistrationController');
Yes, Route::resource automatically creates a set of routes.
https://laravel.com/docs/5.4/controllers#resource-controllers
Laravel resource routing assigns the typical "CRUD" routes to a controller with a single line of code. For example, you may wish to create a controller that handles all HTTP requests for "photos" stored by your application. Using the make:controller Artisan command, we can quickly create such a controller.
It happens when you create a resource route. This way Laravel assigns the typical "CRUD" routes to a controller with a single line of code.
More info: https://laravel.com/docs/5.4/controllers#resource-controllers
i have a problem with my Laravel routes.
if i call the following url: http://laravel/market it works fine, but my site has different languages so i use the LaravelLocalization package and when i call http://laravel/en/market it comes an error:
Route [market.offers.show] not defined.
i have used:
php artisan route:list
to see the indexed routes and here is a shortcut of it:
| GET|HEAD | market/offers | market.offers.index | App\Http\Controllers\Front\OffersController#index
| POST | market/offers | market.offers.store | App\Http\Controllers\Front\OffersController#store
| GET|HEAD | market/offers/bid/{id} | market.offers.bid | App\Http\Controllers\Front\OffersController#bid
| GET|HEAD | market/offers/create | market.offers.create | App\Http\Controllers\Front\OffersController#create
| GET|HEAD | market/offers/history | market.offers.history | App\Http\Controllers\Front\OffersController#history
| POST | market/offers/store/bid | market.offers.store.bid | App\Http\Controllers\Front\OffersController#storebid
| DELETE | market/offers/{offers} | market.offers.destroy | App\Http\Controllers\Front\OffersController#destroy
| GET|HEAD | market/offers/{offers} | market.offers.show | App\Http\Controllers\Front\OffersController#show
| PUT|PATCH | market/offers/{offers} | market.offers.update | App\Http\Controllers\Front\OffersController#update
| GET|HEAD | market/offers/{offers}/edit | market.offers.edit | App\Http\Controllers\Front\OffersController#edit
on other pages i get the same error for Route [market.offers.create]
why is that ? How can i resolve that ?
in your routes you should add a wildcard for the language for example it will look like /laravel/{lang}/market
and then in your controllers you handle the if the lang is null or not to set the default language