Skip to content

Latest commit

 

History

History
56 lines (47 loc) · 1.12 KB

File metadata and controls

56 lines (47 loc) · 1.12 KB

<--Return Home

Composer

Initiate composer in a project:

composer install

This reads composer.json file and creates a Vendor folder with all its stuff for autoloading. Exclude this folder from git. In the entry point of the directory, inside index.php, add this:

require vendor/autoload.php

When you want to update the dependencies/classes subsequently, as in when you want to add new classes you might have created:

composer dump-autoload

Needs sorting

Initiate composer in a project root folder

composer init

Change vendor location by using

"config": {
    "vendor-dir": "includes/vendor"
},

Different methods of including files Documentation.

"autoload": {
    "classmap": [
        // include all folders
        "./", 
        //include only classes in a specified folder
        "myClasses"
    ],
    "psr-4": {
        "Application\\": "app/"
    },
    "files": [
        "helpers/functions.php"
    ]
},

require new packages

composer require webmozart/assert