tuxum wrote > The (well) formatted text: > > Hi all! > I'm trying to use phpBB3 (forum app) along with ZF2. For that, I have to > include a file from the phpBB3. In theory this is as simple as: > > include('/path/to/phpbb3/common.php'); > $user->session_begin(); //$user is defined in common.php file > In common.php a lot of globals are defined, and after that are required > some files which are using those globals. In ZF2 simply including the > common.php would not work, because the scope of the globals will not span > over the required files, so I tried a little trick: > > //in Application/Forum/Service > public function callForumAPI(){ > $zf_dir = getcwd(); > chdir('/var/www/html/phpBB3'); > > include('common.php'); > $user->session_begin(); > > chdir($zf_dir); > } > Neither in this case the scope of the global variables didn't span over > the required files, so all the globals where NULL in those files. How > could I solve this issue? > Thank you!
Includes are in the scope of the method/function they were called in, in this case callForumAPI, so they will only be visible inside that method The easiest way to achieve this, I think, is to move the include and the /$user->session_begin()/ into the public/index.php file so they will be included in the global scope. It is not rally elegant, but elegance is sort of deprecated when having to deal with global variables ;) Hope this helps -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/Including-an-external-application-in-ZF2-tp4661341p4661343.html Sent from the Zend Framework mailing list archive at Nabble.com. -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com