setting up Laravel 4 and looking for a way too sort out the base path for local vs live development.
My website currently runs on 'www.project.com' and then I access the site on local machine as 'localhost:8888/project'.
For things such as CSS and image paths etc I am looking for a way to have a variable for the base paths so I dont have to manually go changing paths etc when switching to live host.
I currently use the environment for my database settings:
$env = $app->detectEnvironment(array(
'local' => array('MacBook.local'),
'production' => array('project.com'),
));
Can I work with something similar to this so its all done automatically?
My css paths in my template blade file are:
'/css/main.css'
And then on local:
'/project/public_html/css/main.css'
Unless there is a way to get the route of what I am trying to do with PHP?
Thanks.
You may use something like this:
<!--Blade-->
<link href="{{ asset('css/main.css') }}" rel="stylesheet" />
<!--Non-Blade-->
<link href="<?php echo asset('css/main.css') ?>" rel="stylesheet" />
This will solve the problem. Check the asset
helper function on the documentation.