Laravel 4 difference between url :: asset () and asset ()

There is a helper for loading assets in Laravel 4 projects to create an asset url

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

But this assistant could be called, using also a facade

 <link rel="stylesheet" href="{{ URL::asset('css/styles.css') }}" /> 

which give the same result.

So my question is, is this the real difference here, one way is better in terms of performance than the other, or just a style of preference

+6
source share
2 answers

This is the asset() function:

 if ( ! function_exists('asset')) { /** * Generate an asset path for the application. * * @param string $path * @param bool $secure * @return string */ function asset($path, $secure = null) { return app('url')->asset($path, $secure); } } 

So both functions are the same. asset() is just a helper function. In particular, helpers are more suitable for viewing. So yes, that is preference. I prefer to use Facades.

+11
source

they are the same. helper function is just an alias.

+2
source

All Articles