Laravel helpers are the globally accessible functions defined by the framework. It can be directly called and independently used anywhere within the application without needing to instantiating an object or importing class.
There are helpers for manipulating Arrays, Paths, Strings, URLs, etc
Array methods[edit | edit source]
This method is used to add new key value pairs to an array.
$array = ['username' => 'testuser']; $array = array_add($array, 'age', 18);
['username' => 'testuser', 'age' => 18]
String methods[edit | edit source]
This method changes a string to camel case
Path mehods[edit | edit source]
Path methods helps easy access to application related paths easily from anywhere.
This method returns the fully qualified public path of the application. which is the public directory.
$path = public_path();
Urls[edit | edit source]
The url function generates a fully qualified URL to the given path.
if your site is
if nothing is passed to the url method it would return an instance of
Illuminate\Routing\UrlGenerator, and it could be used like this
would return current url
would return full url
would return previous url