sauladam / shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.
93 stars 32 forks source link

Hi, How to register a custom tracker? #4

Closed slince closed 7 years ago

slince commented 7 years ago

The library is very surprise. however i want register a tracker. Do you have any idea?

sauladam commented 7 years ago

Hey @slince ,

there is currently no "official" way to add custom trackers. But you can simply put your implementation under the Sauladam\ShipmentTracker\Trackers namespace to make this package aware of it:

<?php

namespace Sauladam\ShipmentTracker\Trackers;

class MyNewTracker {
    // your implementation here
}

Then you can simply use it with ShipmentTracker::get('MyNewTracker');. Just make sure your class is autoloaded, e.g. by adding it to the autoload-section in your composer.json file:

"classmap": [
      "path/to/MyNewTracker.php"
]

You could also extend Sauladam\ShipmentTracker\Trackers\AbstractTracker for some boilerplate if you need it.

I'll try to come up with a more convenient way to add custom trackers. And if you already have one, feel free to PR it :)

slince commented 7 years ago

@sauladam OK PS: I love your avatar

slince commented 7 years ago

@sauladam Hi ! I have created a PR to resolve this.

6

slince commented 7 years ago

@sauladam Hi, Will you accept this PR? I now need to use this feature.

sauladam commented 7 years ago

I've merged your PR, thank you!

teamcoltra commented 6 years ago

@slince Can you make a PR with an update to the documentation?