I have just set up a new laravel 4 project and I can't seem to get my routes to work.
I have the following code in my routes.php file.
Route::get('test', function()
{
return 'test';
});
Route::get('/', function()
{
return View::make('hello');
});
But if I go to localhost:8888/laravel4 I get a directory listing instead of the '/' route.
If I go to localhost:8888/laravel4/test I get The requested URL /laravel4/test was not found on this server.
I am using MAMP with php 5.5.3 for my localhost.
The entry point is in the public directory
So you go to
localhost:8888/laravel4/public/
to get the / route
and
localhost:8888/laravel4/public/test
to the test route.
Otherwise, you should set up a vhost (Don't know how to do in Mac) and point it to the public directory of your laravel project
Related
Can anyone please help me?
Hi. I have tried using Console command to generate the sitemap.xml.
It always generate the default sitemap.xml file.
` urlset xmlns=" http: //www.sitemaps.org/schemas/sitemap/0.9 " `
` xmlns:xhtml = " http: //www.w3.org/1999/xhtml "`
I then tried to use it manually in my routes in order to check whether there is a problem with console command.
It generated the same default xml again.
I thought there might be something wrong with my routes. I then added simple routes like.
Route::get('/', function() {
return view('welcome');
});
Route::get('/about', function() {
return view('welcome');
});
But still it generated that same default xml both from console command and from visiting a route.
The problem was my docker environment. I used laragon on windows, which perfectly create the sitemap.
For google seo kindly do remove dynamic routes from sitemap.
I have just deployed Laravel 5.4 using Composer on a shared hosting and I've run into several problems which I think are now fixed.
The first one was folder permissions which is now fixed so at least I see a welcome page.
I noticed that composer install never create a routes directory so I uploaded a local version and also it never creates a cache directory in the boostrap folder which I fixed also.
I have installed Laravel on a subdomain and I want everything to run through the subdomain as the root folder has a different application.
If i got to the subdomain, the welcome page opens as expected but as soon as I try to use a different route, I get this error:
NotFoundHttpException in RouteCollection.php line 145:
I have looked at what other people have done with subdomains but nothing works for me. I don't know if there are other files are missing during the install
This is what I have in the Routes.php
Route::group(['domain' => 'subdomain.example.com'], function () {
Route::get('/', function () {
return view('welcome');
});
Route::get('test', function () {
return view('welcome');
});
});
I assume every route needs to run in the subdomain route group or do I need to use this at all seeing as the install is in the subdomain directory and the vhost is pointing to the subdomain public folder
It turned out to be a problem with the PHP version the command line was using on Plesk.
Currently Plesk runs in 5.4 and Laravel needed 5.6. For some reason Composer ran successfully and it seemed to miss downloading some of the files.
I wiped everything from the subdomain and thanks to this http://blogs.reliablepenguin.com/2015/08/18/using-php-composer-phar-with-non-default-php-install i was able to run composer using php version 5.6
I didn't need any special route for subdomains as everything is in the subdomain and these routes worked as expected
Route::get('/', function () {
return view('welcome');
});
Route::get('test', function () {
return view('welcome');
});
I am using Ubuntu 16.04 and installed Laravel 5.3 on desktop/Laravel/test directory. I have created a test.blade.php file in resources/view directory. I have also created routes.php in app/Http directory and added following code:
Route::get('/', function(){
return view('test');
});
When I enter command in terminal: php artisan serve and go to http://localhost:8000 url in browser, it shows default page of laravel after installation. Why it is not showing view I have created? I have also tried writing following code in routes.php:
Route::get('/', function(){
echo "Test";
})
But still it doesn't work. Is there anything I am missing?
Reference
By default, fresh Laravel 5.3 applications contain two HTTP route
files in a new top-level routes directory. The web and api route files
provide more explicit guidance in how to split the routes for your web
interface and your API.
The routes.php is moved to different folder in Laravel 5.3. Update routes/web.php file.
From the Laravel Documentation 5.3
The routes directory contains all of the route definitions for your application. By default, three route files are included with Laravel: web.php, api.php, and console.php.
The routes.php was there in previous version. But in laravel 5.3 the routes.php is moved to routes/web.php as Saumini Navaratnam said.
I'm a beginner in frame work Laravel, I'm using Laravel 5.3
- I created a new project - laravel-.
- It run fine on URL "http://localhost/laravel/public/"
- I added a new route called "home" in web.php file as:
<?php
Route::get('/', function () {
return view('welcome');
});
Route::get('/home', function () {
return 'This is home.';
});
I tested "http://localhost/laravel/public/home"
but it return
Not Found
The requested URL /laravel/public/home was not found on this server.
Where is the problem? thank you.
In development phase the easy way around is using "php artisan serve" command. After you deploy the project, you should configure your server's document root as Alexey suggested.
You're using wrong configuration. You should point web server to a public directory:
DocumentRoot "/path_to_laravel_project/public"
<Directory "/path_to_laravel_project/public">
And then use normal URLs like:
http://localhost
http://localhost/home
try
Route::get('/home', function () {
return 'This is home.';
});
Route::get('/', function () {
return view('welcome');
});
Also call it like
http://localhost/laravel/home
Changing the .env.example file in the root project folder to .env worked for me.
Then generate a new APP_KEY using php artisan key:generate
Quick question,
EDIT: I do not know how to access other routes besides '/'
Here are the routes I want to access
Route::get('/', 'HomeController#index');
Route::get('users', 'UserController#index');
Route::get('foo', function()
{
return 'Hello World';
});
Here is my routes. Via php artisan routes
I can successfully access localhost/cartraderlaravel/public
It takes me to HomeController#index
when I try to access foo or users I get
I have tried
localhost/cartraderlaravel/public/users
localhost/cartraderlaravel/users
localhost/cartraderlaravel/foo
localhost/cartraderlaravel/public/foo
All of these return a "Not Found" error. Help anyone?
You should point your root directory to cartraderlaravel/public in WAMP so that you need not to visit localhost/cartraderlaravel/public. To do that in WAMP follow :
Click on WampServer icon in taskbar
Select Apache > httpd.conf from the pullup
Search for the term “DocumentRoot”
Change the DocumentRoot path to your custom directory
Search again for “DocumentRoot” again same procedure
Save your changes and “Restart All Services”
Further research shows this is a common problem with WAMP. Something to do with Apache settings. I have moved to using a virtual network and everything works now