ais / haribundle

充满Hari的包

dev-master / 0.0.1.x-dev 2016-01-11 02:53 UTC

This package is not auto-updated.

Last update: 2024-09-24 18:27:10 UTC


README

为AIS创建的hari Bundle。我在我的工具包中使用了Symfony 2.7.4。如果你想要安装Symfony,请访问以下链接

Symfony 2.7

使用方法

我假设你已经在你的开发环境中安装了composer。如果没有,请访问此链接

开始使用Composer

在你的根目录的composer.json文件的require标签内添加以下内容

{
    "require": {
      "ais/haribundle" : "dev-master"
    },
}

运行composer update,并等待更新完成。

php composer.phar update

在AppKernel.php中注册该bundle

一旦composer update完成。如果你之前尚未安装NelmioApiDocBundle,你也需要注册它。

因为这个bundle需要NelmioApiDocBundle来查看API文档。我还使用了JMS Serializer和FOSRestBundle。

<?php
// app/AppKernel.php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
        ...
            new Nelmio\ApiDocBundle\NelmioApiDocBundle(),
            new FOS\RestBundle\FOSRestBundle(),
            new JMS\SerializerBundle\JMSSerializerBundle(),
            new Ais\HariBundle\AisHariBundle(),
        );
        ...

        return $bundles;
    }
}

将路由导入到你的app/config/routing.yml中

  ais_haris:
    type: rest
    prefix: /api
    resource: "@AisHariBundle/Resources/config/routes.yml"
  
  NelmioApiDocBundle:
    resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
    prefix:   /api/doc

看看里面有什么

现在你通过访问你的url dev可以看到可用的API

ex: https:///web/app_dev.php/api/doc

发现一个错误?请通过PR向我提出。如果你发现一些错误,请通过电子邮件帮助我修复它 vizzlearn@gmail.com