Support the ongoing development of Laravel.io →
posted 8 years ago
Configuration
Last updated 6 months ago.
0

It presumes your url maps to the public/ directory. If you're using MAMP, give this a look: http://sawmac.com/mamp/virtual/ This will allow you to have something like http://client-site.dev which would route to your Sites/client-site/public directory.

Last updated 6 months ago.
0

The asset() helper prepends the base URL to the path you supply.

The base URL is the location of index.php (in this case: http://localhost/laravel/).

If you don't want index.php inside /public you will need to use public/ inside your asset path, like so: asset("public/css/style.css")

Last updated 6 months ago.
0

sgmurphy said:

The asset() helper prepends the base URL to the path you supply.

The base URL is the location of index.php (in this case: http://localhost/laravel/).

If you don't want index.php inside /public you will need to use public/ inside your asset path, like so: asset("public/css/style.css")

Hi sgmurphy, I have another problem. If I building a package which use asset() for get asset file url. Then I install this package to another project. How can I sync the asset folder in anytime I use this package?

Last updated 6 months ago.
0

Please help me. :(

Last updated 6 months ago.
0

I set up my XXAMP environment this way:

<VirtualHost *:85>

DocumentRoot "C:/xampp/htdocs/cats/public"

<Directory "C:/xampp/htdocs/cats/public">

Options Indexes FollowSymLinks Includes ExecCGI

AllowOverride All

Require all granted

</Directory> </VirtualHost>

Public is my base directory and public/index.php is the start file. public includes:

public/css

public/img

public/js

and

<link rel="stylesheet" href="{{asset('css/bootstrap.min.css')}}">

works.

Last updated 6 months ago.
0

Change /Illuminate/Foundation/helpers.php/asset() function as follows:

function asset($path, $secure = null)
{
    return app('url')->asset("public/".$path, $secure);
}
Last updated 6 years ago.
0

Learner said:

Change /Illuminate/Foundation/helpers.php/asset() function as follows:

function asset($path, $secure = null) { return app('url')->asset("public/".$path, $secure); }

Not working with L5

0

Learner said:

Change /Illuminate/Foundation/helpers.php/asset() function as follows:

function asset($path, $secure = null) { return app('url')->asset("public/".$path, $secure); }

Please do not do this. It is a really bad idea to modify framework code.

The change will not persist if you have to update the framework (bug fix). It will also not persist over deployments unless you commit the entire framework to your code repository (also a horrible idea). It also has the effect of possibly introducing bugs into your framework (again something you do not want to do).

The proper solution to this would be to create your own helper function. Take a look at this URL for some good practice suggestions on how to do that - http://stackoverflow.com/questions/28290332/best-practices-for...

0

I don't think that it is a good idea to update packages directly, instead of that we can move the files present in the public folder, by default, to root folder and update the index.php file like below.

require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';

After this,

{{ asset('public/css/style.css') }} 

will refer to the public/css/style.css in both local server and remote server.

The benefit of this method is, the composer update command might update vendor folder, but it won't affect us in any way.

0

Sign in to participate in this thread!

Cloudways

Your banner here too?

kyllynk kyllynk Joined 4 Jun 2014

Moderators

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

Your logo here?

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

© 2022 Laravel.io - All rights reserved.