Dependencies

Overview

All dependencies will be downloaded with composer, since its easy, fast, and clean.


Getting started

To download the dependencies make sure you have your directory structure setup already, as shown here. Go inside your composer.json file and modify it to download all dependencies, like so:

{
 "require": {
  "propel/propel": "~2.0@dev",
  "phpmailer/phpmailer": "^6.0",
  "league/oauth2-client": "^2.2",
  "slim/slim": "^3.9",
  "slim/php-view": "^2.2",
  "paypal/rest-api-sdk-php": "^1.13"
 },
 "autoload": {
  "classmap": [
   "data/models/"
  ],
  "psr-4":{
   "app\\": "app/"
  }
 }
}

and then run

composer install

to get all the dependencies downloaded into the vendor folder.

NOTE: The autoload will not work until you have a folder data/ and models/ inside data/, these folders will be created by propel later, or you can manually create them now.


Explanation of above composer.json

require: {?} lists the dependencies required for the project (propel, slim, etc...)

autoload: {?} lists extras to be included when composer dump-autoload -o is ran. classmap[?] allows directories to be included in the autoload process. The psr-4 autoload is used to define the mapping from namespaces to directories. The example filename would be app/hello.php containing an app\hello class.


Notes

Make sure that any of the composer commands are ran in the same directory as the composer.json, or the commands will fail. Composer will download the dependencies into a vendor/ directory, which it will create if it doesn't exist. Every dependency will have a directory, for example, propel will be inside vendor/propel.composer dump-autoload -o will not work in the previously shown composer.json example if data/models and app/ directories don't exist. If you want to test it, simply remove everything except require: {?}. Always run

composer dump-autoload -o

after installing a new dependency in order to load up the new files, or the new dependencies will go unused.

Comments (0)

Search Here