killerwolf/jcdecauxcyclocity-bundle

此软件包提供了集成JCDecaux提供的Cyclocity OpenData Rest API的简易方法

0.1.0 2014-10-12 16:39 UTC

This package is not auto-updated.

Last update: 2024-09-24 07:22:09 UTC


README

Scrutinizer Code Quality SensioLabsInsight Dependency Status

这是一个用于在Symfony2项目中使用JCDecaux Cyclocity OpenData Rest API的简单软件包

安装

使用composer安装,并在kernel中启用此软件包。

使用方法

首先,在app/conf/config.yml中添加您的API密钥(来自jcdecaux开发者门户)

killerwolf_jc_decaux_cyclocity:
    api_key: "YOU_API_KEY"

最后,在您的控制器中使用此服务

<?php

namespace Killerwolf\JCDecauxCyclocityBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

class DefaultController extends Controller
{
    public function indexAction(Request $request)
    {
    	$api = $this->get('cyclocity.data');

        return $this->render(
            'KillerwolfJCDecauxCyclocityBundle:Default:index.html.twig', 
            [
                'stations' => $api->getStationsByContract( 'Paris' )
            ]
        );
    }
}