The Blog

Laravel 5

Laravel 5

Laravel 5: Generating Paths Relative to the Storage Directory With storage_path

John Koster
John Koster
April 14, 2018

Learn how to utilize the storage_path function in Laravel to get the path to the storage directory or construct relative paths. See code examples for different use cases and how to add a trailing slash to the returned path.

Laravel 5

Laravel 5: Generating Public URLs to Elixir Compiled Assets With elixir

John Koster
John Koster
April 14, 2018

Learn how to use the elixir helper function in Laravel 5.4 to get the path to a versioned Elixir file. By default, the function looks in the build directory, which is relative to the public directory. However, you can also specify a custom build directory. In Laravel 5.4, Laravel Elixir was renamed to Laravel Mix, so be sure to use the mix helper function instead.

Laravel 5

Laravel 5: Generating Public URLs to Mix Compiled Assets With mix

John Koster
John Koster
April 14, 2018

Learn how to use the mix helper function in Laravel to generate URLs for versioned assets. This function generates a URL with a hash as the versioned filename, allowing you to reference assets compiled or minified using Laravel Mix. If you need to change the manifest directory, you can specify it as the second parameter of the mix function. Make sure the directory contains the mix-manifest.json file or it will throw an exception.

Laravel 5

Laravel 5: Generating Secure URLs to Assets With secure_asset

John Koster
John Koster
April 14, 2018

The secure_asset function in Laravel returns a URI composed of the application's URI and the given $path, always using https as the protocol. It is essentially a call to the asset helper function with the $secure parameter set to true. If the supplied $path or a domain name contains a protocol, that protocol will be used instead. For example, if a URI with the http:// protocol is supplied to the secure_asset function, the resulting URI will contain the http:// protocol.

Laravel 5

Laravel 5: Generating URLs to Assets With asset

John Koster
John Koster
April 14, 2018

The asset function in Laravel returns a URI composed of the application's URI and the given file path. By default, it uses the http:// schema, but you can set it to https:// by passing true as the second argument. This function is useful for generating asset paths in your application, such as for CSS or JavaScript files.

Laravel 5

Laravel 5: Generating URLs to Controller Actions With action

John Koster
John Koster
April 14, 2018

Learn about using the action helper function in Laravel to generate URLs to controller actions. Provide the name of the controller action as an argument to the $name parameter, and include any required or accepted parameters in the $parameters parameter. The function will automatically add the root namespace of the controller, so there's no need to include it. To generate a full URL, set the $absolute parameter to false. Remember to supply the appropriate namespaces if they are not part of the root namespace. Example: action('ExampleController@sayHello', ['name' => 'Jim'], false); Would generate the URL /sayHello/Jim.

Laravel 5

Laravel 5: Generating URLs to Named Routes With route

John Koster
John Koster
April 14, 2018

The route helper function in Laravel generates URLs for named routes. It takes three parameters: the route name, optional parameters for the URL, and a boolean to indicate if a fully qualified URL should be returned. By default, the function returns a fully qualified URL. You can customize the resulting URL by adding data to the query string.

Laravel 5

Laravel 5: Generating URLs With url

John Koster
John Koster
April 14, 2018

The url helper function in Laravel is a versatile function that can be used to generate URLs to specific paths or return an instance of the URL Generator class. It can be used to generate arbitrary URLs and can also include router parameters in the generated URL. By supplying a true argument to the $secure parameter, you can generate secure URLs.

Laravel 5

Laravel 5: Hashing Strings With bcrypt

John Koster
John Koster
April 14, 2018

The bcrypt function takes a value and returns a hashed representation of that value. It can also accept an array of options that affect how the hash is computed. Each invocation of the function will produce a different result, even if the input remains the same. One of the available options is the rounds option, which controls the number of iterations used to generate the final hash. The default value for rounds is 10, and increasing the value will increase the time required to compute the hash.

Laravel 5

Laravel 5: Logging Informative Messages With info

John Koster
John Koster
April 14, 2018

The info helper in Laravel allows you to write an information entry into the log files. It takes a $message as a parameter and an optional $context array. The $context array can contain any data, even if it's not an array itself. The example provided demonstrates the usage of the info helper and shows what the logged output would look like. Additionally, the examples show equivalent methods calls that can be used to achieve the same result.

Latest posts

Where Things get Good: Moving on to Forte Development Phase 1

Wrapping up Forte Phase 0 with the lexer and parser now in private alpha, and kicking off Phase 1 wi...

Read more
Forte Update: Backtracking, Metadata, HTML Validation, and More

A Forte development update: the parser now supports backtracking, improvements to node metadata, ide...

Read more
Parsing HTML and Blade Attributes in Forte

Wrapping up attribute parsing in Forte's HTML parser, from simple HTML attributes to complex, edge-c...

Read more
Switch Statements and Parser Extensions in Forte

Exploring how Forte's parser extensions can be used to handle complex Blade directives like nested s...

Read more
Parsing Blade Comments in Forte

Digging into parsing Blade and HTML comments while building Forte's HTML parser for Laravel Blade.

Read more
Thoughts on HTML Elements and Blade Components in Forte

This week I’m tackling Forte's HTML parser - consolidating Blade, Flux, and Livewire components into...

Read more