Search

In Laravel 5

Laravel 5: Generating CSRF Session Tokens With csrf_token

Apr 14, 2018

Learn about the csrf_token function in Laravel, which retrieves the CSRF token from the session storage. The CSRF token is a random string 40 characters long, generated using the str_random(40) function call. You can use the csrf_token function to generate the token and include it in your HTML forms using the csrf_field method, making your forms secure against cross-site request forgery attacks.
Laravel 5: Generating HTTPS URLs With secure_url

Apr 14, 2018

The secure_url helper function generates secure, fully qualified URLs to a given path in Laravel. It can also add additional data as a query string by supplying parameters. Internally, secure_url returns the value of the url helper function. An example use of secure_url is demonstrated, with the resulting URL being dependent on the path and domain name. To generate URLs with extra data, parameters can be supplied in an array.
Laravel 5: Generating Paths Relative to the Application Installation Directory With base_path

Apr 14, 2018

Learn how to use the base_path function in Laravel to retrieve the path to the application's directory and construct relative paths. Check out examples that demonstrate its usage and understand how it differs from the app_path function.
Laravel 5: Generating Paths Relative to the Application Root With app_path

Apr 14, 2018

The app_path function in Laravel returns the full path to the application directory. The value returned depends on your specific folder structure. You can also use app_path to build paths relative to the application directory by supplying a string as the argument. However, keep in mind that the function does not automatically add a trailing forward slash to the returned path, so you may need to use the str_finish function to ensure it is present.
Laravel 5: Generating Paths Relative to the Configuration Directory With config_path

Apr 14, 2018

The config_path function in Laravel retrieves the path to the config directory and can also be used to construct paths relative to the configuration directory. By providing a $path, you can easily generate paths to specific configuration files. For example, calling config_path('database.php') will return the full path to the database.php configuration file in the Laravel application.
Laravel 5: Generating Paths Relative to the Database Directory With database_path

Apr 14, 2018

The database_path function in Laravel can be used to retrieve the directory path of the database. It can also construct paths relative to the database directory by supplying a parameter. For example, calling database_path('migrations') will return the path to the migrations directory in the Laravel application.
Laravel 5: Generating Paths Relative to the Public Directory With public_path

Apr 14, 2018

Learn how to use the public_path function in Laravel to get the path to the public directory or construct relative paths. The function takes an optional path parameter and does not automatically add a trailing slash to the returned string. Find out how to add the trailing slash using the str_finish function.
Laravel 5: Generating Paths Relative to the Resource Directory With resource_path

Apr 14, 2018

The resource_path helper function in Laravel can be used to resolve the path to the resource directory, or to a sub-directory or file within the resources directory. It does not append the trailing forward slash, but you can use the str_finish function to add it if needed.
Laravel 5: Generating Paths Relative to the Storage Directory With storage_path

Apr 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: Generating Public URLs to Elixir Compiled Assets With elixir

Apr 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: Generating Public URLs to Mix Compiled Assets With mix

Apr 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: Generating Secure URLs to Assets With secure_asset

Apr 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: Generating URLs to Assets With asset

Apr 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: Generating URLs to Controller Actions With action

Apr 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.

Some absolutely amazing
people

The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.