I have a Symfony2 controller in which I want to include a file containing common functions. However, when I use the require statement, I get an error that the request was unexpected. In addition, in PHPStorm, I also get an error that only functions can be declared where I have a require statement.
Here is an overview of my code:
<?php namespace AppBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Response; use ReCaptcha\ReCaptcha; class MyController extends Controller { private $salt_length = 10; private $resources; private $request; private $session; private $message; private $loggedin;
The request at the end of my class creates a compiler error.
I would prefer not to create another package and use it, because I want the MyController scope to act when functions are called in the .php utility.
Is there another preprocessor directive that includes the contents of a file in another in order to achieve what I'm trying to do?
Oddly enough, when I look, turn on and demand that the php manual and w3schools php pages seem to say that you can use include / require to accomplish exactly what I'm trying to do here.
Thank you in advance for any help anyone can give me.
include php symfony
Howard Brown Dec 15 '16 at 1:26 2016-12-15 01:26
source share