Search

Laravel URL Helper Function: secure_url

November 21, 2016 —John Koster

secure_url($path, $parameters = [])

The secure_url helper function can be used to generate secure, fully qualified URLs to a given $path. You can also supply additional data that will be added as a query string by supplying an argument for the $parameters parameter.

The secure_url helper function internally returns the value of a call to the url(discussed in the Laravel URL Helper Function: url article) helper function.

The following example demonstrates the usage of the secure_url helper function:

1<?php
2 
3$url = secure_url('arbitraryUrl');

The resulting URL would look similar to the following output. The exact URL will change depending on the $path and the domain name.

1https://laravel.artisan/arbitraryUrl

To generate URLs with extra data, supply an argument for the $parameters array like so:

1<?php
2 
3$url = secure_url('arbitraryUrl', [
4 'someParameter'
5])

The resulting URL would be similar to the following output:

1https://laravel.artisan/arbitraryUrl/someParameter

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.