如何包含自定义php文件?

时间:2017-02-18 22:38:05

标签: php symfony

我已将新目录和新文件添加到src/AppBundle。所以路径是:src/AppBundle/Helper/Helper.php

我的控制器的路径与往常一样src/AppBundle/Controller/MyController.php

我现在想将文件Helper.php包含在我的Controller中。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

假设您在Symfony 2.8中>>> b array([1, 2, 3, 2, 3, 4]) >>> np.sum(b, axis=0) 15 >>> np.sum(b, axis=1) Traceback (most recent call last): File "<input>", line 1, in <module> np.sum(b, axis=1) File "/usr/local/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 1814, in sum out=out, **kwargs) File "/usr/local/lib/python3.6/site-packages/numpy/core/_methods.py", line 32, in _sum return umr_sum(a, axis, dtype, out, keepdims) ValueError: 'axis' entry is out of bounds 看起来像是这样的一种可能性:

AppBundle/Controller/MyController

您的助手课程包括namespace AppBundle\Controller\MyController use Symfony\Bundle\FrameworkBundle\Controller\Controller; class MyController extends Controller { ... }

然后,您可以在public function getSomeHelp()中定义服务:

services.yml

并在你的MyController中:

services
    app.helper:
        class: 'AppBundle\Helper\Helper'
相关问题