How to change the default landing page after serve command - php

I am wondering if it is possible to change the default startup address after the command
php artisan serve
Because when I run it, I get the default url
Starting Laravel development server: http://127.0.0.1:8000
But my "first page" is when I type
http://127.0.0.1:8000/index
in the browser.
So is it possible to automatically give out http://127.0.0.1:8000/index after startup?

If you want to show your index.blade.php at first place then just replace in your routes/web.php
From this
Route::get('/', function () {
return view('welcome');
});
TO this
Route::get('/', function () {
return view('index');
});

Related

Laravel routes dont show

I am completely new to laravel, so I think my question is a bit ridiculous.
I tried to create a route in the routes/web.php
Route::get('/example', function () {
Return ('hello');
)};
But when I try to see the example page, I receive 404.
I use php artisan serve to load the local host.
I couldn't find a solution relatable to my situation. Still no luck.
Windows version 8.1
Laravel version 8
Also I can't edit
Route::get('/', function () {
Return view ('welcome');
});
The changes won't apply
Thank you
You can type php artisan route:list to see if the route saved or not, if not you can write :
php artisan optimize:clear
Your syntax is not correct.
Route::get('/example', function () {
Return view('hello');
});
Make your hello.blade.php file add your html code that is your view file.run command php artisan route:clear.
you must use:
php artisan:serve
then
your_app_url/example
and edit web.php -- you have syntax error in web.php
Route::get('/example', function () {
return 'hello';
});

The get in laravel doesn't find any page

I am very a beginner in Laravel
I launch my laravel project on localhost
<http://localhost/ecommerce/public/>
Route::get('/', function () {
return view('welcome');
});
this give me the welcome page
But I want to add about page but it always say "404 Not found"
and that's my code:
Route::get('/about', function () {
return view('about');
});
I made a file in views and called it "about.blade.php"
when I type to view about like this :
Route::get('/', function () {
return view('about');
});
and remove the welcome get, it works and give the about page
but when I put it in get "/about" it always doesn't work, even if I just type "string"
why it can't recognize get "/about"?
You should run the project with php artisan serve in terminal or in the server you have to change document root and remove the public in URL
the reason is the extra public in your url

PHP Laravel route after installation

I installed new laravel project("Starter") and want to view the 'welcome' page by putting this URL.
http://localhost/starter/
The page ran fine when the route is the following.
Route::get('/', function () {
return view('welcome');
});
However, when I write any thing after the (/)...
Route::get('/test', function () {
return view('welcome');
});
And view it by URL:
http://localhost/starter/test
The page doesn't work and shows...
404
Not Found
Any ideas?
(s) in word (starter) in the URL, shoud be UpperCase (Starter) as the name of Laravel project

Change the route in Aimeos Laravel

I am using Aimeos e-commerce on a Laravel site, I want to change the store route to /shop but I get an the browser doesn't open a page I do it as follows
Route::get('/shop', function () {
return redirect('shop');
})->name('shop');
but when I make on "/" main page it displays perfectly. How to change its route?
Use this in your route/web.php file:
Route::get('/', function () {
return redirect('shop');
});
See https://github.com/aimeos/aimeos/blob/master/routes/web.php

How to properly define the home (/) route in Laravel?

Let's say I am defining the following route in Laravel 5.3:
Route::resource('bands', 'BandController');
The default route example coming when you start a new Laravel project has the following:
Route::get('/', function () {
return view('welcome');
});
How do I make bands route to be the default one when no controller is called instead of welcome? Meaning /?
I did read docs here but didn't found anything. Any?
Place that block inside laravel/app/routes.php instead of a Controller (4.x)
Place that block inside laravel/app/Http/routes.php instead of a Controller (5.1)
Place that block inside laravel/app/routes/web.php instead of a Controller (5.3)
Route::get('/', function()
{
return view('welcome');
});
You can redirect default to anywhere you want, i.e.:
Route::get('/', function()
{
return Redirect::to( '/bands');
// OR: return Redirect::intended('/bands'); // if using authentication
});
As #Patrick mentioned, you can simply redirect to the /bands route. However, I have to warn you that the redirect will actually change the URL in the navigation pane of the web browser. I would have suggested that you just ask the home route to use the index method of your BandController as follows:
Route::get('/', ['uses'=>'BandController#index']);

Categories