PHPackages                             canaltp/navitia - 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. canaltp/navitia

ActiveLibrary[API Development](/categories/api)

canaltp/navitia
===============

A library to interract with Navitia Api (https://api.navitia.io)

v3.2.2(1y ago)8120.6k↓29.4%112MITPHPPHP &gt;=8.0.2CI passing

Since Aug 29Pushed 1y ago34 watchersCompare

[ Source](https://github.com/CanalTP/NavitiaComponent)[ Packagist](https://packagist.org/packages/canaltp/navitia)[ RSS](/packages/canaltp-navitia/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (6)Versions (62)Used By (2)

Navitia Component
=================

[](#navitia-component)

Navitia Component is a PHP library to query **Navitia** Api (), and controls query parameters.

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

[](#requirements)

- PHP: &gt;=7.4
- a Navitia token

> Note: If you don't have a Navitia token yet, you have to register here:

Choose your version
-------------------

[](#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
------------

[](#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 ?
-----------------------------

[](#how-to-use-navitiacomponent-)

### By autowire

[](#by-autowire)

In services.yaml file of your app, add this :

```
    navitia_component:
        class: Navitia\Component\Service\ServiceFacade
        factory: [Navitia\Component\Service\ServiceFacade, getInstance]
        calls:
            - [ setCache, ["@cache.app.taggable"]]
            - [ setConfiguration, ["%navitia_config%"]]
```

And then add `@navitia_component` to the service that used NavitiaComponent like this :

```
    App\Service\Navitia:
        class: App\Service\Navitia
        arguments: ['@navitia_component']
```

Set configuration:

You can pass an array of config with the `setConfiguration` function.

```
namespace App\Service;

use Navitia\Component\Service\ServiceFacade;

class Navitia
{
    private ServiceFacade $navitiacomponent;

    function __construct(ServiceFacade $navitiacomponent)
    {
        $this->navitiacomponent = $navitiacomponent;
        // Configuration
        $config = array(
            'url' => 'api.navitia.io',
            'token' => '3b036afe-4242-abcd-4242-99718476c2e0', // Example of token
        );
        $this->navitiacomponent->setConfiguration($config);
    }
}
```

NameTypeDescriptionAccepted valuesDefault 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:

```
$query = array(
    'api' => 'journeys',
    'parameters' => array(
        'from' => '2.3749036;48.8467927',
        'to' => '2.2922926;48.8583736',
    ),
);

$result = $this->navitiacomponent->call($query); // Returns an object with Api result
```

Config parameters:

### Uses cases

[](#uses-cases)

Navitia component supports these apis:

- Journeys
- Coverage
- Departures

#### Journeys

[](#journeys)

Example of an itinerary:

```
$query = array(
    'api' => 'journeys',
    'parameters' => array(
        'from' => '2.3749036;48.8467927',
        'to' => '2.2922926;48.8583736',
    ),
);

$result = $this->navitiacomponent->call($query);
```

See also:

#### Coverage

[](#coverage)

Example, retrieve metadata about a coverage:

```
$query = array(
    'api' => 'coverage',
    'parameters' => array(
        'region' => 'sandbox',
    ),
);

$result = $this->navitiacomponent->call($query);
```

See also:

#### Departures

[](#departures)

Example, get all next departures of a line and at a datetime:

```
$query = array(
    'api' => 'departures',
    'parameters' => array(
        'region' => 'sandbox',
        'path_filter' => '/lines/line:RAT:M1/departures?from_datetime=20160615T1337'
    ),
);

$result = $this->navitiacomponent->call($query);
```

See also:

### Calling any other Api

[](#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:

```
$query = array(
    'api' => 'coverage',
    'parameters' => array(
        'region' => 'sandbox',                          // Coverage name
        'path_filter' => 'stop_areas?variable=value',   // Url to call
    ),
);

$result = $this->navitiacomponent->call($query);
// Will call http://api.navitia.io/v1/coverage/sandbox/stop_areas?variable=value
```

### Using query builder

[](#using-query-builder)

You can use a query builder:

```
use Navitia\Component\Request\JourneysRequest;
use Navitia\Component\Request\Parameters\JourneysParameters;

$query = new JourneysRequest();

$actionParameters = new JourneysParameters();

$actionParameters
    ->setFrom('2.3749036;48.8467927')
    ->setTo('2.2922926;48.8583736')
    ->setDatetime('20160819T153000')
;

$query->setParameters($actionParameters);

$result = $this->navitiacomponent->call($query);
```

Using query builder to get all next departures:

```
use Navitia\Component\Request\Parameters\CoverageDeparturesParameters;
use Navitia\Component\Request\DeparturesRequest;

$query = new DeparturesRequest();
$query->setRegion('sandbox')->setPathFilter('lines/line:RAT:M1');

$actionParameters = new CoverageDeparturesParameters();
$actionParameters->setDuration(1);
$actionParameters->setFromDatetime('20160615T1337');
$actionParameters->setForbiddenUris(['lines', 'modes']);
$actionParameters->setDataFreshness('realtime');

$query->setParameters($actionParameters);

$result = $this->navitiacomponent->call($query);
```

Running Tests
-------------

[](#running-tests)

For this part, you should use docker (need install) and launch it with :

```
make all_tests_dev
```

License
-------

[](#license)

The library is under [MIT](LICENSE).

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community33

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor3

3 contributors hold 50%+ of commits

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.

###  Release Activity

Cadence

Every ~68 days

Recently: every ~48 days

Total

60

Last Release

668d ago

Major Versions

v0.38.2 → v1.0.02014-11-04

v1.4.0 → v2.0.02021-03-10

v1.4.1 → v2.1.02021-10-07

v2.1.0 → v3.0.02022-01-27

PHP version history (2 changes)v2.1.0PHP &gt;=7.4.8

v3.0.0PHP &gt;=8.0.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/7a2e84adf3e1bbfcc1c525e8875141708cf5f34a58676c5389c951016a632fb3?d=identicon)[packagistctp](/maintainers/packagistctp)

![](https://www.gravatar.com/avatar/dda7e458a209d5394bcf3015ddc298b49dd8cae89304ac89b3ec0f0ead48b1d6?d=identicon)[packagist-kisio-bot](/maintainers/packagist-kisio-bot)

---

Top Contributors

[![RubiksC](https://avatars.githubusercontent.com/u/8112018?v=4)](https://github.com/RubiksC "RubiksC (37 commits)")[![pthegner](https://avatars.githubusercontent.com/u/6606900?v=4)](https://github.com/pthegner "pthegner (26 commits)")[![dvdn](https://avatars.githubusercontent.com/u/7195916?v=4)](https://github.com/dvdn "dvdn (19 commits)")[![tchevily](https://avatars.githubusercontent.com/u/8125361?v=4)](https://github.com/tchevily "tchevily (11 commits)")[![Netmisa](https://avatars.githubusercontent.com/u/1167753?v=4)](https://github.com/Netmisa "Netmisa (10 commits)")[![vchabot](https://avatars.githubusercontent.com/u/715331?v=4)](https://github.com/vchabot "vchabot (9 commits)")[![alcalyn](https://avatars.githubusercontent.com/u/1588144?v=4)](https://github.com/alcalyn "alcalyn (5 commits)")[![johnny3](https://avatars.githubusercontent.com/u/3646286?v=4)](https://github.com/johnny3 "johnny3 (4 commits)")[![lrocheWB](https://avatars.githubusercontent.com/u/10560073?v=4)](https://github.com/lrocheWB "lrocheWB (4 commits)")[![VincentCATILLON](https://avatars.githubusercontent.com/u/8419208?v=4)](https://github.com/VincentCATILLON "VincentCATILLON (4 commits)")[![rchoquet](https://avatars.githubusercontent.com/u/2551773?v=4)](https://github.com/rchoquet "rchoquet (4 commits)")[![ooga](https://avatars.githubusercontent.com/u/3911114?v=4)](https://github.com/ooga "ooga (2 commits)")[![datanel](https://avatars.githubusercontent.com/u/187239?v=4)](https://github.com/datanel "datanel (2 commits)")[![is06](https://avatars.githubusercontent.com/u/631559?v=4)](https://github.com/is06 "is06 (2 commits)")[![Msaglier](https://avatars.githubusercontent.com/u/11887082?v=4)](https://github.com/Msaglier "Msaglier (1 commits)")[![sami602](https://avatars.githubusercontent.com/u/3872388?v=4)](https://github.com/sami602 "sami602 (1 commits)")[![stanosz](https://avatars.githubusercontent.com/u/6775311?v=4)](https://github.com/stanosz "stanosz (1 commits)")[![jbcrestot](https://avatars.githubusercontent.com/u/1705417?v=4)](https://github.com/jbcrestot "jbcrestot (1 commits)")[![Chrysem](https://avatars.githubusercontent.com/u/10496713?v=4)](https://github.com/Chrysem "Chrysem (1 commits)")[![velpaxl](https://avatars.githubusercontent.com/u/5991797?v=4)](https://github.com/velpaxl "velpaxl (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/canaltp-navitia/health.svg)

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M386](/packages/easycorp-easyadmin-bundle)[oro/platform

Business Application Platform (BAP)

645143.5k115](/packages/oro-platform)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M738](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)

PHPackages © 2026

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