Support the ongoing development of Laravel.io →
posted 9 years ago
Requests
Last updated 2 years ago.
0

Can you elaborate more on your setup? Neither 'localhost/classifieds/public/admin/categories' nor 'localhost/classifieds/public/admin/categories/' are correct URLs in a default Laravel App (Unless you modified it somehow). If Laravel is setup correctly your URL should be 'localhost/admin/categories' (which is where in fact it is trying to take you). Therefore your corresponding routes would be localhost/admin/ for AdminController and localhost/admin/categories for CategoriesController

Make sure you are serving the /public directory as your document root otherwise things will break without some modification.

Last updated 9 years ago.
0

cringer said:

Can you elaborate more on your setup? Neither 'localhost/classifieds/public/admin/categories' nor 'localhost/classifieds/public/admin/categories/' are correct URLs in a default Laravel App (Unless you modified it somehow). If Laravel is setup correctly your URL should be 'localhost/admin/categories' (which is where in fact it is trying to take you). Therefore your corresponding routes would be localhost/admin/ for AdminController and localhost/admin/categories for CategoriesController

Make sure you are serving the /public directory as your document root otherwise things will break without some modification.

Well, my localhost is G:\xampp\htdocs. My project folder: G:\xampp\htdocs\classifieds How will I check if I 'm serving the /public directory as my document root? I have installed laravel using composer, so I thought no changes were needed. And, if it's of any importance, this is my G:\xampp\htdocs\classifieds\bootstrap\paths.php:

return array(
	'app' => __DIR__.'/../app',
	'public' => __DIR__.'/../public',
	'base' => __DIR__.'/..',
	'storage' => __DIR__.'/../app/storage',
);

And G:\xampp\htdocs\classifieds\server.php:

<?php

$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);

$uri = urldecode($uri);

$paths = require __DIR__.'/bootstrap/paths.php';

$requested = $paths['public'].$uri;

// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' and file_exists($requested))
{
	return false;
}

require_once $paths['public'].'/index.php';
Last updated 9 years ago.
0

In G:\xampp\htdocs\classifieds\app\config\php.php I changed from 'url' => 'http://localhost' to 'url' => 'http://localhost/classifieds'.

In G:\xampp\htdocs\classifieds\public.htaccess I added: RewriteBase /laravel/public/

But nothing.

0

If you just installed laravel in your htdocs then your /public directory is not being served. Unfortunately I don't know a whole lot about xampp but I know you need to setup a virtual host that points to your project public folder. A quick google search should bring some information on how to set this up.

0

In this video they edit file G:\xampp\apache\conf\httpd.conf. They change DocumentRoot "G:/xampp/htdocs". But if I change this, then other projects on the same server will use the new value, which would be wrong. Right? So, there must be some 'correct' way, I suppose.

Last updated 9 years ago.
0

I 'm trying to make a Virtual host, this is my document root:

G:\xampp\apache\conf\httpd.conf:
DocumentRoot "G:/xampp/htdocs"
<Directory "G:/xampp/htdocs">

Following the instructions from this video: https://www.youtube.com/watch?v=U4WfrmKNhj4 :

In file G:\xampp\apache\conf\original\extra\httpd-vhosts.conf I added:

NameVirtualHost *:80
<VirtualHost *:80>    
    DocumentRoot "G:/xampp/htdocs/classifieds/public"
    ServerName laravel.dev
    ServerAlias laravel.dev
    ErrorLog "logs/laravel.log"
    CustomLog "logs/custom.laravel.log" common

<Directory "G:/xampp/htdocs/classifieds/public">
Options Indexes MultiViews FollowSymLinks
                AllowOverride All
                Order allow, deny
                Allow from all
				Require all granted
        </Directory>
</VirtualHost>

In file G:\WINDOWS\system32\drivers\etc\hosts I added:

127.0.0.1       laravel.dev

But it doesn't work. So I added in file httpd.conf, at the end:

#Virtual hosts
Include G:\xampp\apache\conf\original\extra\httpd-vhosts.conf

But, after adding this line, Apache doesn't even start!

Last updated 9 years ago.
0

I was using the wrong file:G:\xampp\apache\conf\original\extra\httpd-vhosts.conf While the correct is in another folder...:G:\xampp\apache\conf\extra\httpd-vhosts.conf

0

But now I get the error 'Method [index] does not exist'.

This method does exist in the controller and was working before I made the Virtual host.

Edit: I had to change the routes:

Route::group(array('prefix' => 'admin'), function()
{
    Route::resource('subcategories', 'SubcategoriesController');        
    Route::controller('categories', 'CategoriesController');
    Route::resource('/', 'AdminController');
});

Route::resource('categories', 'CategoriesController'); replaced with: Route::controller('categories', 'CategoriesController');

Last updated 9 years ago.
0

panosss said:

In this video they edit file G:\xampp\apache\conf\httpd.conf. They change DocumentRoot "G:/xampp/htdocs". But if I change this, then other projects on the same server will use the new value, which would be wrong. Right? So, there must be some 'correct' way, I suppose.

Yes, if you do it like the video says you would change your main document root which would affect all projects. You should create a separate vhost for your laravel project so it should have no impact on anything else.

Last updated 9 years ago.
0

panosss said:

I 'm trying to make a Virtual host, this is my document root:

G:\xampp\apache\conf\httpd.conf:
DocumentRoot "G:/xampp/htdocs"
<Directory "G:/xampp/htdocs">

Following the instructions from this video: https://www.youtube.com/watch?v=U4WfrmKNhj4 :

In file G:\xampp\apache\conf\original\extra\httpd-vhosts.conf I added:

NameVirtualHost *:80
<VirtualHost *:80>    
   DocumentRoot "G:/xampp/htdocs/classifieds/public"
   ServerName laravel.dev
   ServerAlias laravel.dev
   ErrorLog "logs/laravel.log"
   CustomLog "logs/custom.laravel.log" common

<Directory "G:/xampp/htdocs/classifieds/public">
Options Indexes MultiViews FollowSymLinks
               AllowOverride All
               Order allow, deny
               Allow from all
  			Require all granted
       </Directory>
</VirtualHost>

In file G:\WINDOWS\system32\drivers\etc\hosts I added:

127.0.0.1       laravel.dev

But it doesn't work. So I added in file httpd.conf, at the end:

#Virtual hosts
Include G:\xampp\apache\conf\original\extra\httpd-vhosts.conf

But, after adding this line, Apache doesn't even start!

Typically you don't modify the main http.conf, but just the vhosts.conf in your extra directory. On WAMP Server (which I use over XAMPP) I modify the apache\conf\extra\httpd-vhosts.conf but also have to enable vhosts support in the php.ini. I wonder if thats the case in XAMPP.

0

panosss said:

But now I get the error 'Method [index] does not exist'.

This method does exist in the controller and was working before I made the Virtual host.

Edit: I had to change the routes:

Route::group(array('prefix' => 'admin'), function()
{
   Route::resource('subcategories', 'SubcategoriesController');        
   Route::controller('categories', 'CategoriesController');
   Route::resource('/', 'AdminController');
});

Route::resource('categories', 'CategoriesController'); replaced with: Route::controller('categories', 'CategoriesController');

Does that mean everything's working now?

0

cringer said:

panosss said:

But now I get the error 'Method [index] does not exist'.

This method does exist in the controller and was working before I made the Virtual host.

Edit: I had to change the routes:

Route::group(array('prefix' => 'admin'), function()
{
   Route::resource('subcategories', 'SubcategoriesController');        
   Route::controller('categories', 'CategoriesController');
   Route::resource('/', 'AdminController');
});

Route::resource('categories', 'CategoriesController'); replaced with: Route::controller('categories', 'CategoriesController');

Does that mean everything's working now?

This replacement (resource->controller) fixed these controller methods:

index 
create

These methods don't work:

show
edit
store
update I don't know because I can't test it (because edit doesn't work)
destroy

omg it's really exhausting!

Does this mean I will have to make a route for every controller method? Instead of one route I had for every controller? (with route::resource)

Last updated 9 years ago.
0

But I suppose, my real problem is that 'route::resource' stopped working after I added the VirtualHost. How can I find the cause of this problem?

0

panosss said:

But I suppose, my real problem is that 'route::resource' stopped working after I added the VirtualHost. How can I find the cause of this problem?

Check your routes and make sure that all your resource routes are mapped.

php artisan route:list
0

I made another laravel installation and copied files there. It seems to work ok. I suppose it would take me much longer to find the problem. Anyway thank you for your help!

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

panosss panosss Joined 18 Jan 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.