Loading RocketShipIt

Loading

Loading RocketShipIt into your project is as easy as requiring a single file called, autoload.php.

Example:

<?php
require 'autoload.php'; // This autoloads RocketShipIt classes

$rate = new \RocketShipIt\Rate('ups'); // Load the actual class

Loading with Composer

Loading RocketShipIt into your project with other libraries is easy with Composer.

Given the following directory structure:

├── common
│   └── lib
│       └── Shipping
│           ├── LICENSE
│           ├── RocketShipIt
│           ├── autoload.php
│           └── config.php
├── composer.json
├── composer.phar
├── myapp.php

Your Composer.json file will look like this:

{
    "autoload": {
        "files": ["common/lib/Shipping/RocketShipIt/RocketShipIt.php"],
        "psr-0": {
            "RocketShipIt\\": "common/lib/Shipping/"
        }
    }
}

Note

The files section is required at the moment as RocketShipIt comes with a few functions that are not yet in PSR-0 classes.

CodeIgniter

There should be a default third_party folder within the CI applications directory.

RocketShipIt should be added to this directory. The final structure should look like this:

applications/
└── third_party
    └── RocketShipIt
        ├── LICENSE
        ├── RocketShipIt
        ├── autoload.php
        └── config.php

Your class might look something like this:

<?php
class Track extends MY_Controller {

function __construct() {
    parent::__construct();
    require_once APPPATH . 'third_party/rocketshipit/autoload.php';
}

Laravel 5+

Add RocketShipIt to composer.json autoload section. Example:

"autoload": {
    "classmap": [
        "database"
    ],
    "files": ["libs/RocketShipIt/RocketShipIt/RocketShipIt.php"],
    "psr-0": {
        "RocketShipIt\\": "libs/RocketShipIt/"
    },
    "psr-4": {
        "App\\": "app/"
    }
},

run composer dump-autoload to generate a new autoload file.

Create a libs folder in your project root and add RocketShipIt to it. It should look like this:

libs/
└── RocketShipIt
    ├── LICENSE
    ├── RocketShipIt
    ├── VERSION
    ├── autoload.php
    └── config.php

You should now be able to call RocketShipIt classes from anywhere in your app.