duanrenchuo9244 2015-01-15 08:50
浏览 32

命名空间的最佳实践:在Symfony上,使用(子)命名空间时的perf差异?

I'm building an API and I would ask something about using namespaces on a Symfony2 controller.
Is there a real difference doing :

<?php

namespace My\APIBundle\Controller;

use FOS\RestBundle\Controller\Annotations\View,
    FOS\RestBundle\Controller\Annotations\Post,
    FOS\RestBundle\Controller\Annotations\Get;
use [...]

class MyRestController extends Controller {

    [...]

    /**
     * @View()
     * @Get()
     */
    public function getAction(Thing $thing) {
        return $thing;
    }

    /**
     * @View()
     * @Post()
     */
    public function postAction() {

    }

or doing

<?php

namespace My\APIBundle\Controller;

use FOS\RestBundle\Controller\Annotations as Rest;
use [...]

class MyRestController extends Controller {

    [...]

    /**
     * @Rest\View()
     * @Rest\Get()
     */
    public function getAction(Thing $thing) {
        return $thing;
    }

    /**
     * @Rest\View()
     * @Rest\Post()
     */
    public function postAction() {

    }

Would the alias load everything in the given namespace, losing perfs ? Or will it load only annoted classes, unitary ?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)