Laravel uses composer for dependencies management. Put calendar in the app/Libraries folder, and use ‘files‘ property because it is a 3rd party external library.

Recap: Composer autoload

Now move on to an important Composer feature: autoload. Autoloading is a way to automatically include the necessary files when a class is used in an application, without having to manually include or require each file. This can greatly simplify the organization and maintenance of your codebase.

So instead of having to manually include a large number of files at the top of each script, you can simply use the classes you need and let the autoloader handle the rest. You can organize your code into different namespaces and directories, without having to worry about manually including the correct files.

In other words, Composer autoload replaces the old way of using include and require on top of every PHP script.

More about autoloading: https://getcomposer.org/doc/01-basic-usage.md#autoloading

Autoload a 3rd party library manually

To add a 3rd party library, such as PHPEventCalendar, to the autoload section in Composer, It is recommended to use “files” autoloading method

This method allows you to specify a list of files that should be included in the autoloader. You can add the files entries to the “autoload” section of your composer.json file like this:


"autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App": "app/"
        },
        "files": ["app/Libraries/phpEventCalendar/conf.php"]

    },

Don’t forget to run composer dump-autoload

It is important to note that when you use the classmap and files autoloading method, you need to run the composer dump-autoload command after adding or modifying the files/classmap, for the autoloader to be updated.


composer dump-autoload