Download the PHP package canaltp/navitia without Composer
On this page you can find all versions of the php package canaltp/navitia. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download canaltp/navitia
More information about canaltp/navitia
Files in canaltp/navitia
Package navitia
Short Description A library to interract with Navitia Api (https://api.navitia.io)
License MIT
Informations about the package navitia
Navitia Component
Navitia Component is a PHP library to query Navitia Api (https://api.navitia.io), and controls query parameters.
Requirements
- PHP: >=7.4
- a Navitia token
Note: If you don't have a Navitia token yet, you have to register here: https://navitia.io/register
Choose your version
-
NavitiaComponent v1.x.x used by legacy projects in production (example NMM Realtime)
-
NavitiaComponent v2.x.x compatible with frameworks like Symfony4
-
NavitiaComponent v3.0.0 compatible with modern frameworks like Symfony5.4, with old firm name CanalTP
- NavitiaComponent v3.1.x compatible with modern frameworks like Symfony5.4, with present firm name Hove
Installation
Using composer:
composer require "hove/navitia":"^3.1"
example for previous versions (before v3.1.x, deprecated)
composer require "canaltp/navitia":"~2.0"
How to use NavitiaComponent ?
By autowire
In services.yaml file of your app, add this :
And then add @navitia_component
to the service that used NavitiaComponent like this :
Set configuration:
You can pass an array of config with the setConfiguration
function.
Name | Type | Description | Accepted values | Default value |
---|---|---|---|---|
url (required) |
string |
Base url of Navitia | ||
token (required) |
string |
Your token | ||
timeout |
int |
Navitia timeout (in ms) | 6000 |
|
version |
string |
Api version | v1 |
v1 |
format |
string |
Wanted output format | json , object |
object |
Query example:
Config parameters:
Uses cases
Navitia component supports these apis:
- Journeys
- Coverage
- Departures
Journeys
Example of an itinerary:
See also: http://doc.navitia.io/#journeys
Coverage
Example, retrieve metadata about a coverage:
See also: http://doc.navitia.io/#coverage
Departures
Example, get all next departures of a line and at a datetime:
See also: http://doc.navitia.io/#departures
Calling any other Api
To query Navitia with any other url using this component and the config you have provided, this pattern do the trick:
Using query builder
You can use a query builder:
Using query builder to get all next departures:
Running Tests
For this part, you should use docker (need install) and launch it with :
License
The library is under MIT.
All versions of navitia with dependencies
psr/log Version 2.0.*
symfony/validator Version 5.4.*
symfony/cache Version 5.4.* || ^6.0
doctrine/annotations Version ^1.13
doctrine/cache Version ^2.1