I have laravel project on a mac running OSX el capitan with php artisan . The project runs without problem, but for personal reasons I want to use xampp apache instead of artisan server so when I try to load the index.blade.php instead of loading the view this appears.
Do the same procedure but on a PC with Windows 7 and the XAMPP loads without any problem, my App doesn't know why it doesn't run on the Mac, any idea?
the url i try to access is
http://localhost/sisVentas/resources/views/almacen/categoria/index.blade.php
the route.php file is as follows:
<?php
/*
*/
Route::get('/', function () {
return view('welcome');
});
/*
Route::get('crearusuario',function(){
return "URL crearusuarioasdadasd";
});
*/
//carpeta dentro de VISTAS almacen
Route::resource('almacen/categoria','CategoriaController');
The funny thing is that when I try to simply access localhost with xampp, instead of loading the laravel welcome, the following appears:
1.- You are accessing the wrong route. In order to access Laravel, you must go to the public folder, which is where everything will be loaded.
2.- Another option is to configure the virtual hosts of your Xampp so that you can access those projects in an easier way. To do that is very simple
configure host windows
Configure Xampp httpd-vhosts
you add the following
<VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/sisVentas/public/" ServerName sisventas.com
</VirtualHost>
Restart the xammp service and you will be able to access the route sisVentas.com directly
NOTE: the routes in mac hosts will vary, such is the case in the Hosts route for mac is /etc/hosts and for the route in xampp it is depending on where your xampp is located
Another way to access a more correct route directly with your Laravel app is by executing the command
serve
I'll give you an example with Windows...
- Open console window(CMD)
- Go to the path of your app through the console ( cd C:/xampp/htdocs/miAppenLaravel )
- Run the command
php artisan serve
- Go to the browser and enter the route given by the previous command ("localhost:8000")
I don't know what version of Laravel you are using to work, but in OSX it already comes with an internal mini server that allows you to run the project without having to configure Apache, to install the plugin you must do the following in the terminal:
After that you always execute the following in the terminal:
Then you go to the browser and you can open the project through a local domain similar to this:
all this without doing anything more than a couple of configurations and you will have your local miniserver ready without configuring apache or additional tools.