PHPackages                             alexpechkarev/parcelforce - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. alexpechkarev/parcelforce

ActiveLibrary[API Development](/categories/api)

alexpechkarev/parcelforce
=========================

Parcelforce expressTransfer API for Laravel to generate pre-advice electronic file that required by solution.

223PHP

Since Aug 12Pushed 11y ago1 watchersCompare

[ Source](https://github.com/alexpechkarev/parcelforce)[ Packagist](https://packagist.org/packages/alexpechkarev/parcelforce)[ RSS](/packages/alexpechkarev-parcelforce/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Parcelforce expressTransfer API for Laravel 4
=============================================

[](#parcelforce-expresstransfer-api-for-laravel-4)

[**Parcelforce exrpessTransfer**](http://www.parcelforce.com/)API for [**Laravel**](http://laravel.com/) to generate pre-advice electronic file that required by solution.

[![Build Status](https://camo.githubusercontent.com/c64ae72aa1e7a6785b902d787b19b00e3e75a1ef1b9bca46301748d2bbebb52c/68747470733a2f2f7472617669732d63692e6f72672f616c6578706563686b617265762f70617263656c666f7263652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/alexpechkarev/parcelforce)

Features
--------

[](#features)

- Generating electronic file on the server
- Submitting electronic file to [**Parcelforce**](http://www.parcelforce.com/)
- Single or multiply consignment's per file
- UK Domestic collection request (Label and receipt provided by PFW driver)
- UK Domestic services dispatches only (Label printed by customer)
- Can be used as Laravel package or PHP standalone class

Requirements
------------

[](#requirements)

Must be [**Parcelforce**](http://www.parcelforce.com/account-customer/benefits-of-parcelforce-account) customer
PHP &gt;= 5.3
MySQL
[**Laravel**](http://laravel.com/) &gt;= 4.1 if used as Laravel package

Installation
------------

[](#installation)

```
composer require alexpechkarev/parcelforce  dev-master
```

Configuration
-------------

[](#configuration)

Once installed, register Laravel service provider, in `app/config/app.php`:

```
'providers' => array(
	...
    'Parcelforce\ExpressTransfer\ParcelforceServiceProvider',
)
```

Publish configuration file:

```
php artisan config:publish parcelforce/expresstransfer --path vendor/alexpechkarev/parcelforce/src/config/
```

All generated file will be stored in `app/config/packages/parcelforce/expresstransfer/files` folder by default. Ensure this folder writable by the web server:

```
chmod o+w app/config/packages/parcelforce/expresstransfer/files
```

Name and location of this folder can be specified in the configuration file by editing `filePath` value, if changed ensure it's writable by we server.

```
    /**
     * Location consignment files
     */
    'filePath'                        => __DIR__.'/files/',
```

In the configuration file `app/config/packages/parcelforce/expresstransfer/config.php` please ensure that following parameters are set. For more details on configuration options and required values please contact [**Parcelforce**](http://www.parcelforce.com/contact-us). By default these parameters preset with dummy values.

```
 'header_customer_account'
 'header_generic_contract'
 'senderName'
 'senderAddress1'
 'senderPostTown'
 'senderPostcode'
 'dr_consignment_number'
 'fileName'
 'ftpUser'
 'ftpPass'
 'ftpUploadPath'
 'ftpLocationPath'

```

Laravel Usage
-------------

[](#laravel-usage)

Simply pass you data as array to `Parcelforce::process()` method. Electronic file will be generated for given data, stored at `filePath` location and submitted to Parcelforce.

```
        $senderData = array(
            array(
                "deliveryDetails"=>array(
                    'receiverName'      =>"MR CUSTOMER",
                    'receiverAddress1'  =>'100 CUSTOMER SOLUTIONS STREET',
                    'receiverPostTown'  =>'MILTON KEYNES',
                    'receiverPostcode'  =>'MK9 9AB'
                    )
            )
        );

        Parcelforce::process($senderData);

        // generate file locally without submitting to Parcelforce
        Parcelforce::process($senderData, FALSE);
```

Multiply consignment data can be submitted in single request.

```
        $senderData = array(
            array(
                "deliveryDetails"=>array(
                    'receiverName'      =>"MR CUSTOMER",
                    'receiverAddress1'  =>'100 CUSTOMER SOLUTIONS STREET',
                    'receiverPostTown'  =>'MILTON KEYNES',
                    'receiverPostcode'  =>'MK9 9AB'
                    )
            ),
            array(
                "deliveryDetails"=>array(
                    'receiverName'      =>"MR CUSTOMER",
                    'receiverAddress1'  =>'202 CUSTOMER SOLUTIONS STREET',
                    'receiverPostTown'  =>'MILTON KEYNES',
                    'receiverPostcode'  =>'MK9 9AB'
                    )
            )
        );

        Parcelforce::process($senderData);
```

By default collection date is set for tomorrow's date and can be amended in the configuration file, see `collectionDate`. This value can also be specified at runtime using `Parcelforce::setDate()` method.

```
    Parcelforce::setDate("next Monday");
    Parcelforce::process($senderData);
```

Dates handled by:

- [**Carbon**](https://github.com/briannesbitt/Carbon) in package for Laravel
- [**DateTime**](http://php.net/manual/en/book.datetime.php) in PHP standalone class

Following formats accepted by `setDate()` method:

[**Relative Formats**](http://php.net/manual/en/datetime.formats.relative.php)

- tomorrow
- next wednesday
- this thursday
- ....

[**Date Formats**](http://php.net/manual/en/datetime.formats.date.php)

- 2014-08-11
- 08/11/2014
- 20140811
- ....

PHP standalone class Usage
--------------------------

[](#php-standalone-class-usage)

Location: 'Parcelforce\\ExpressTransfer\\PHP'

Standalone class have same methods as Laravel package and accepts consignment data in the same way. Before use please ensure that required parameters are set in configuration file 'Parcelforce/ExpressTransfer/PHP/config.php' and `Parcelforce/ExpressTransfer/PHP/files` folder is writable by web server.

```
       $pf = new \Parcelforce\ExpressTransfer\PHP\Parcelforce();
       $pf->process($senderData));

       // generate file locally without submitting to Parcelforce
       $pf->process($senderData));
```

`setDate()` method is also available in standalone version.

```
    ...
    $pf->setDate("next Monday");
    $pf->process($senderData);
```

Configuration testing
---------------------

[](#configuration-testing)

For testing and configuration purposes file can be generated without being submitted to Parcelforce. To generate file locally simply pass `FALSE` as second parameter to `process()` method.

```
    // In Laravel package
    Parcelforce::process($senderData, FALSE);

    // In PHP standalone class
    $pf->process($senderData, FALSE);
```

Once testing and configuration completed file and consignment numbers have to be reset to initial values. To initiate process call `reset()` method. Please note: `reset()` will reload database tables and all the data will be lost. See `config.php` for table details.

```
    // In Laravel package
    Parcelforce::reset();

    // In PHP standalone class
    $pf->reset();
```

PHPUnit Testing
---------------

[](#phpunit-testing)

PHPUnit testing require [**Mockery**](https://github.com/padraic/mockery) flexible PHP mock object framework. Run following command to install Mockery:

```
composer require mockery/mockery:dev-master@dev

```

In Laravel package test file needs copying from package folder into `app/tests/` folder, use following to do so:

```
cp vendor/alexpechkarev/parcelforce/tests/ParcelforceLaravelTest.txt app/tests/ParcelforceTest.php

```

And then run test:

```
phpunit app/tests/ParcelforceTest.php
```

To test PHP standalone file ensure database credentials are set in the config file.

```
    phpunit vendor/alexpechkarev/parcelforce/tests/ParcelforcePHPTest.php
```

Main Methods
------------

[](#main-methods)

```
     /**
     * @param array $data - array of data
     * @return string File content
     */
     public function process($data, $upload = TRUE)

    /**
     * Drop database tables
     */
    public function reset()

    /**
     * Get file content
     * @return string
     */
     public function getFileContent()

    /**
     * Get current instance config file
     * @return array
     */
    public function getConfig()
```

Support
-------

[](#support)

[Please open an issue on GitHub](https://github.com/alexpechkarev/parcelforce/issues)

License
-------

[](#license)

Parcelforce expressTransfer API for Laravel 4 is released under the MIT License. See the bundled [LICENSE](https://github.com/alexpechkarev/parcelforce/blob/master/LICENSE)file for details.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1cc8e1ca17a8158b131c60f92d5c5243073bfa762fb34b9263c0fbc15f072132?d=identicon)[alexpechkarev](/maintainers/alexpechkarev)

---

Top Contributors

[![alexpechkarev](https://avatars.githubusercontent.com/u/5559162?v=4)](https://github.com/alexpechkarev "alexpechkarev (75 commits)")

### Embed Badge

![Health badge](/badges/alexpechkarev-parcelforce/health.svg)

```
[![Health](https://phpackages.com/badges/alexpechkarev-parcelforce/health.svg)](https://phpackages.com/packages/alexpechkarev-parcelforce)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M186](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M33](/packages/facebook-php-business-sdk)[microsoft/microsoft-graph

The Microsoft Graph SDK for PHP

65723.5M95](/packages/microsoft-microsoft-graph)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
