I have just installed laravel 5.7. So, In web.php I have defined Route.. Like
Route::get('foo', function () {
return 'Hello World';
});
But when i Hit the URL -> http://localhost/rp/public/foo
It shows me 404 page not found.
use PHP's built-in development server, you may use the serve Artisan command:php artisan serve
Later you can check in browser like this: http://localhost:8000/foo
If you have to check without artisan serve
Route::get('/foo', function () {
return 'Hello World';
});
you can check like this(rp is your laravel-project-name): http://localhost/rp/public/foo
you must have a configuration like this in your .htaccess file
Related
I got this exception for this route: http://localhost:8000/ and other route that I wrote in routes.php file and when I wrote
php artisan route:list
I got this message
Your application doesn't have any routes.
I didn't change anything in my code and it worked successfully.I searched about it but I couldn't find an exact answer why this problem happened.
this is routes.php
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for 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 () {
$name = ['saba','safavi'];
return view('welcome'/*,compact('name')*/);
});
Route::get('/sabasafavi', function () {
return "Salam saba safavi";
});
Route::get('/contact-us', function () {
return view("contact-us");
});
\Illuminate\Support\Facades\Route::get('/user/{id}',function ($id){
return "hello user : ".$id;
})/*->where(['id'=>'[0-5]+'])*/;
\Illuminate\Support\Facades\Route::get('/user/{name}/comment/{number}',function ($name,$number){
$comment = "Hello ".$name." this is your comment</br> number : ".$number;
return $comment;
});
/*Route::post('/send',function (){
return "OK information saved successfully";
});*/
First make sure your web.php is being loaded on RouteServiceProvider.php
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
or it might be that your old empty web.php it has been cached since you have cache enabled so do : php artisan route:clear then run php artisan route:list
this problem is because of renaming your Laravel applications.
If you are using an IDE like PHPStorm or sublime do a full search (find in files) (Edit->Find->Find in Path) of laravel5learning across all files in your project directory and all sub-directories and then change it to App
then run php artisan route:list
Please try
php artisan serve
this command and this will give you something like this http://127.0.0.1:8000. So that in localhost you just add this and then your route like -
http://127.0.0.1:8000/
here'/' is your default route i used/
hope will work for you
My laravel project is showing this error: NotFoundHttpException in RouteCollection.php when i am trying to sync my project to github using github desktop, except for this route:
Route::get('/', function () {
return view('welcome');
});
but another simple route like following will not work, and return that error.
Route::get('loa', function () {
return view('loa');
});
In route list, using route command: php artisan route:list it says it exists. but it always returns Route not found. I also have tried to use the command dump-auto load or route:clear, but nothing is working.
Run composer update then try again.
my php project with lumen is ok on my computer with WAMP (windows.apache.mysql.php) environment.
but when i upload it to my server on with LNMP (Linux,nginx,mysql,php) environment,
i enter the URL , it came to HTTP ERROR 500
the root is
/home/wwwroot/www.projectname.cn/projectname/public;
So i put a test.php at "/home/wwwroot/www.projectname.cn/projectname/public"
enter www.projectname.cn/test.php
it's the right page.
so i change the index.php
<?php
$app = require __DIR__.'/../bootstrap/app.php';
dump($app);
//$app->run();
also is HTTP ERROR 500
and at local environment , i add a route in projectname/app/Http/routes.php
<?php
$app->get('/', function() use ($app) {
return $app->welcome();
});
$app->get('/hello', function() {
return "hello ";
});
i enter “www.projectname.cn/hello” it also doesn't work
the routes.php doesn't work
what's maybe the reason caused that ??
You can see the error log dynamically using the command
tail -f /var/log/nginx/error.log
This is the default nginx configuration in Debian/Ubuntu, so you could have to change error.log route.
I 'm new to LARAVEL 5 ,so i have created about.blade.php in ~/project/resources/views and then add this code in app/routes.php in order to view the page when requested in browser:
Route::get('about', function () {
return view('about');
});
========================================================================
Then i requested in browser as this : http://localhost:8000/about .
so this error is shown in browser :
[
I solved this issue using sudo command with php artisan serve
It was Permission issue .
I have just installed fresh laravel 5.1, only root page is showing that
Route::get('/', function () {
return view('welcome');
});
It's working perfectly but rather than any other route not working
like:
Route::get('user', function () {
return "hello";
});
It throws exception 404 not found. Please help me to get out from this. Thanks in advance.
It may be because of rewrite mode is not enabled in your system. Either you enable it or access through the following url with index.php
http://localhost/blog/public/index.php/user