Route is not working when I access laravel application through localhost - laravel

I have a laravel project and I can access this application through virtual server (tracking.com) locally. When I run through virtual server all the routes are working perfectly. But when I access the application through localhost (localhost/tracking/public) routes are not working except home page.
Home Route
Route::get('/', 'DashboardController#info')->middleware('auth');
Non-working routes
Route::resource('depot', 'DepotsController')->middleware('auth')
All routes are working well with virtual server. With virtual server both routes are working home page(tracking.com) and depots page (tracking.com/depot).
but with localhost only (localhost/tracking/public) is working and (localhost/depot) is not working.

There are three solutions to this issue -
1) If you have Apache or Nginx installed, configure your vhost to point to /public/ directly
2) Use Laravel Homestead
3) Navigate to your project-folder/ within your terminal and run php artisan serve, you can now browse to http://localhost:8000 directly in your browser
Ref: If you are going with the first approach - Click here

use php artisan serve and navigate to 127.0.0.1:8000 from they all the routes will work

Related

Using Valet to serve two projects on sub domains using proxy

I have two projects one is API(Laravel APP) and another one is a frontend app(Nuxt APP). I want to serve these projects on the same domain using valet on my local. Problem is that I'm not able to do so as both my subdomains are pointing to the frontend app(Nuxt APP). Following are the steps to reproduce the issue
Step 1:
Here each subdomain has been registered using the following commands and is pointing to the right directory,
valet link api.nuxttodo
valet link app.nuxttodo
Note: At this point, if I access api.nuxttodo.test it do successfully open the API(Laravel App)
Two links(sub-domains) that are generated after running these commands are as follows
Step 2:
After that I have added a proxy for the app.nuxttodo.test domain using the command because my frontend app(Nuxt App) is running on http://localhost:60539
valet proxy app.nuxttodo http://localhost:60539
One proxy is as follows
Problem:
Now issue is that both subdomains are now pointing to the same project. Both api.nuxttodo.test and app.nuxttodo.test URL are now opening the frontend app(Nuxt APP) and I'm not able to access my API(Laravel App) which was accessible before running the proxy.
I'm running the same setup and I only used valet link in the Laravel directory.
For the Frontend project, I use valet proxy.
You should unlink the frontend valet unlink app.nuxttodo as that might be causing the issue.

Laravel not working on remote server only test echo working

I am newbie to Laravel and first time setup the laravel app on remote server, I install laravel and configure with domain name by apache config but I am getting blank page on hitting url, For test I just echo test on public/index.php and its showing correctly but welcome page doesn't work, I don't know where I am making mistake.
This is fresh laravel app I have install directly on server
The question was vague.
Have you configure the route.php to your view welcome.blade.php

Laravel version: 5.4.28 api routes not working on localhost

I downloaded Laravel 5.4.28 and created one api route. Nothing works on localhost. I am using XAMPP on Windows 8.1 as local development.
But everything is working fine on server. I also notice one strange thing. It will work on localhost if I create virtual host on localhost. like below.
php artisan serve
Is that true? or Am I missing anything?
My api routes are like this...
http://localhost:1234/adminapi/public/api/v1/authenticateuser
If your XAMPP works normally with normal PHP pages, did you check which version of php XAMPP uses ? the minimum required version is
PHP >= 5.6.4
Laravel Official Website
The default version of XAMPP's PHP framework is 5.6.30
I have faced the same problem, it turned out that I had only problem with PHP version I just upgraded the version of php.ini from 5.6.3 to 7.0.1 new versions of XAMPP have them both !
First of all you need to create virtual host for your project like yourprojectname.local. and test your app through this url.If you not create virtualhost then you need to give whole path for access laravel api like localhost/yourprojectdirectory/public/adminapi/public/api/v1/authenticateuser
You can bellow link refer to the creating virtual host
http://foundationphp.com/tutorials/apache_vhosts.php
OR
How To Set Up Apache Virtual Hosts on XAMPP (Windows)
When you do php artisan serve and load the URL returned by that command do you see laravels welcome page? If not then you haven't installed it correctly. https://laravel.com/docs/5.4
The php artisan serve command doesn't create a virtual host, it is just a shortcut for the PHP Builtin Webserver, something PHP has out of the box, so the point of using it is to start testing your application as fast as you could, you just need to install PHP, Composer and your application is up (if you don't need anything else, of course). But if you already have Nginx installed, there is no point at all, just use it.
It's not wise to use the Builtin Webserver in production.
There's a property in config/app.php called url.
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => env('APP_URL', 'http://localhost'),
By default it links to .env file's property called APP_URL. XAMP usually requires you to navigate to localhost/project_folder before you can even access your project, hence why you need to set your url property to the one you're using.
Second, API routes usually are prefixed with /api/ and do require a X-REQUESTED-WITH: XMLHttpRequest header.
If you install fresh laravel app, you base api prefix must be equal api.
you route in api.php
Route::get('test', 'TestController#test');
If now you run php artisan serve command, api will be available to
localhost:8000/api/test.
Hope, I help you.
I was facing the same with Apache on Windows. Following the next steps below, it worked for me.
First, look for your file httpd.conf into Apache.
Find the section...
<Directory /var/www/>
Change
AllowOverride None
to
AllowOverride All
Finally, restart the Apache service.

Laravel directory to welcome page on a VPS

Before I was in a shared hosting and had no problem installing and accessing (click next next), Laravel welcome page but I have moved to a bare metal VPS and I am having difficulties to get to the Laravel 5 welcome page. My host tells me to upload the framework to the htdocs directory, but that is exactly what I did and where the app et al are found.
This is the URL scenario.
My web VPS by default shows me its own index.html like this
/var/www/virtual/myweb.com/htdocs/index.html
and yes, I can correctly access that index through myweb.com
but, of course, all my views are in their Views folder, like this:
/var/www/virtual/myweb.com/htdocs/resources/views/welcome.blade.php
my routes page (as it is a freshly installed) naturally
Route::get('/', function() {
return view('welcome');
});
and the URL in my config/app.php file
'url' = >env('APP_URL', http://myweb.com');
If I do something like this in the URL browser box of course, I get to the file of Laravel 5 welcome page
http://www.myweb.com/resources/views/welcome.blade.php
but obviously I don't want to show such path
so, I would like to be able to write myweb.com and directly show my welcome.blade.php
Any ideas as to how?
You should point you web server (Apache) to a public directory of Laravel's project. For example:
DocumentRoot "/var/www/virtual/myweb.com/public/"
<Directory "/var/www/virtual/myweb.com/public/">
After rebooting web server normal URLs should work (if you'll set up correct settings).

Laravel installation on NGINX

I've created a droplet in www.digitalocean.
I've installed NGINX, PHP5 and MYSQL. So far so good.
I've setup Nginx Server Blocks (Virtual Hosts):
zzzz.com
If I go to the browser and type zzzz.com it will display what I have in:
/var/www/zzzz.com/html/index.html
But now I've added Laravel. And supposedly I should see the laravel home page when I go to my http:// server_name
Can anyone help me please.

Resources