Search code examples
phpsymfonyclasssymfony-3.2

Call static method on classes without namspaces


I have a library that don't uses namespaces but uses only static methods, how could I make it available throughout the application? I'm using Symfony 3.2


Solution

  • This can be done in your composer.json file for autoloading:

    "autoload": {
        "files": ["/path/to/my/file/with/functions.php"]
    }
    

    Read more: https://codingexplained.com/coding/php/composer-autoloading-third-party-libraries-without-namespaces

    Don't forget to run composer dump-autoload to rebuild the cached autoloader.