Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

make a global php function in laravel so that accessed anywhere

function your_function( $parameters ) {
    //function logic
} 

function your_another_function( $parameters ) {
    //function logic
} 

// composer.json
"autoload": {
    ...
    "files": [
        "app/Helpers/your_helper_function.php"
    ]
    ...
}

// Now call from any class of Laravel
class UserController extends Controller {
   
  public function storeUser() {
  	your_function();
    
    // do other stuffs
  }

}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #global #php #function #laravel #accessed
ADD COMMENT
Topic
Name
2+9 =