1"autoload": {
2 "files": [
3 "app/helpers.php"
4 ],
5 "classmap": [
6 "database/seeds",
7 "database/factories"
8 ],
9 "psr-4": {
10 "App\\": "app/"
11 }
12},
13
1Create a helpers.php file in your app folder and load it up with composer:
2
3"autoload": {
4 "classmap": [
5 ...
6 ],
7 "psr-4": {
8 "App\\": "app/"
9 },
10 "files": [
11 "app/helpers.php" // <---- ADD THIS
12 ]
13},
14
15After adding that to your composer.json file, run the following command:
16
17composer dump-autoload
18
1$callback = function ($value) {
2 return (is_numeric($value)) ? $value * 2 : 0;
3};
4
5$result = with(5, $callback);
6
7// 10
8
9$result = with(null, $callback);
10
11// 0
12
13$result = with(5, null);
14
15// 5
1"autoload": {
2 "classmap": [
3 "database/seeds",
4 "database/factories"
5 ],
6 "psr-4": {
7 "App\\": "app/"
8 }
9},
10"autoload-dev": {
11 "psr-4": {
12 "Tests\\": "tests/"
13 }
14},
15