Links and Route not working - laravel

I am facing route problem I am using laravel 5.4 and xampp.
I use this address 'localhost/project/laravel/public' to go to home page.
When I click on any link in navigation region, I get object not found.
After clicking, address shows http://localhost/about
I edit home.blade.php as
href = "./" and "./about" By adding period
problem solved to some extent
but when I am on another page
e.g login page address is http://localhost/project/laravel/public/users/login
and if I want to go to contact page, again object not found message received
This time address is http://localhost/project/laravel/public/users/contact
I also tried href="{{ url('/contact')}}" in home.blade.php
The problem remains same.
and
php artisan serve
localhost:8000 gives 'unable to connect'
Please guide, thanks.

What you're doing is wrong, you aren't suppose to navigate to your project's public folder via the browser url... You just need to go to your laravel project folder and run Command prompt and type "php artisan serve". it will generate a url for you. entering that url on your browser will load your project properly and that way all links will work.

Related

Laravel application will not route properly

I am trying to create a first application using TCPDF and Laravel 8. I have an initial page which has a listing of users from a MySQL table and two buttons (Download PDF and View PDF)
There are three routes setup in my web.php file:
Route::get('/', 'App\Http\Controllers\UserController#index');
Route::get('download', 'App\Http\Controllers\PDFTestController#savePDF')->name('download');
Route::get('viewpdf', 'App\Http\Controllers\PDFTestController#openPDF')->name('viewpdf');
I have tried creating the buttons and their actions several different ways but the result is always the same:
// The download button
<button type="button" onclick="window.location='{{ route("download")}}'" class="btn btn-success btn-sm">Download PDF</button>
// The view button
Open PDF
The route for the home page correctly calls App\Http\Controllers\UserController#index and the expected page is displayed.
However, when I try the download page all I get is a 404 "The requested URL was not found on this server." and the URL it is trying is .../LaravelPDF/public/download
Clicking the View button results in a 404 as well and the URL is /LaravelPDF/public/viewpdf
I put some DD() calls in the various functions and it does not appear that they are ever being called. Instead Laravel is trying to open a view named download or viewpdf.
I even tried creating a download.blade.php file but that does not open either.
What am I doing wrong? Thank you in advance for your help.
Just Run your terminal
php artisan route:clear

My site doesnt output laravel page...What shoud i do?

On browser, typing localhost/spa1/public or spa1.test doesn't output the laravel. I've been stuck and cant even proceed to starting my project because of this. I really need help!!
The output supposedly :
enter image description here
The app key is :
APP_KEY=base64:lEpLqsi9GOqaz6eyu5VaTft0UOfj7u+A4LAie6LEJoc=
I'm using xampp on windows
My problem is y it doesnt output the Laravel page like the Google one?
In your terminal, you should start the server.
php artisan serve
This will create a home URL like localhost:8000 and read index.php file in the public folder.
BTW, the image you share is Laravel's default home page. If you look at welcome.balde.php file, you can see the same content there. So your app is running. But it's not a good idea to display your app without artisan serve.
Your code is fine, and this is how the home page looks like in Laravel 8. Because the home page you're talking about was in Laravel 7 & below. And from Laravel 8 onwards, the default home page of Laravel 8 is updated and looks like the one you're getting right now.

Laravel 5.6 Routing doesn't work

First, I am not new to Laravel. I don't understand why this problem happens. I'm working with Laravel on Homestead. When I first load app, welcome screen appears. Then I change routing, "Sorry, the page you are looking for could not be found" appears. I remove all the routing web.php file, delete welcome blade file, again reload root url welcome page appears. Though I don't have any route in web.php and welcome.blade.php file. I clear cache, try some different things, but same thing happens again.
your problem is with homestead and not with laravel , the welcome page you seen is not the laravel welcome page.
Try to make the correct path for your project directory . and follow the laravel homestead doc

Annoying text every page in Laravel web app

This is driving me crazy, but for some reason I have the letters "vd" before all rendered content on each page of my site in my Laravel app. Basically the letters "vd" appear at the top of every page (website, not the actual code) before the navbar or any other content. They also appear when ever I run a php artisan command. For example
C:\Users\Thomas\Git\Webapp> php artisan view:clear
vdCompiled views cleared!
-- OR --
C:\Users\Thomas\Git\Webapp> php artisan serve
vdLaravel development server started: <http://127.0.0.1:8000>
I've checked all my views and can't find the letters "vd" anywhere, but figure it must be coming from something being processed before the view because I get it running simple "php artisan" commands.
I have also tried running the webapp from "C:\wamp\www\Webapp" using WAMP and still get the "vd" text.
Probably you have the "vd" string at the top of a bootstrap file, (config, service provider, route) before the php open tag!
Try a global search in your project and find if you have vd anywhere in your whole project. may be somewhere it can be found. try to search in index.php and bootstrap.php, server.php

Set Laravel Application Urls

Fairly new to Laravel here and I'm struggling to understand how to make Laravel 5.2 aware of where it resides. Here's the issue:
I set up auth using php artisan make:auth, and can now see the lovely landing page, as well as login and register links in the menu. The problem is that these links don't go to the right place. They point to /login and /register in the code respectively, which translates into http://localhost/login or http://localhost/register. But since I'm not on a production site yet and am developing locally, my website resides at http://localhost/projectname/public.
I've gone into config/app.php and tried various values for the URL parameter, but these have no effect.
What can I do to get these links to reflect the full site URL, without manually entering it each time?
you can run the development server in laravel using this command
php artisan serve
Did you try that?
Use laravel url function:
{{ url().'/login' }}

Resources