Open vrkansagara opened 8 years ago
Ping :+1: @ezimuel and @weierophinney
@vrkansagara this example of integration with Symfony is quite old, I didn't check for a while. The idea here is to execute the bootstrap part of a Symfony app. The error that you reported shows a problem of autoloading for the Symfony components. Are you sure that your Symfony app is working fine without Apigility? I suggest to have a look at composer.json.
@ezimuel Yes my symfony working fine independently and apigility as well. The root cause I find that there a one package name called kriswallsmith
is common in apigility and symfony so it generating the errors.
But any way I have figure it out how to resolve it. Thanks a lot to sharing a POC.
here is my recent code which is working fine under the apigility under the PostResource.php
.
require_once '/home/vallabh/www/symfony2app/web/app.php';
$kernel = new \AppKernel('prod', true);
$kernel->loadClassCache();
$kernel->boot();
$this->doctrine = $kernel->getContainer()
->get('doctrine')
->getManager();
I would like to ask you that if possible than can you make a POC for the magento. A contact book or any other idea which is built on zf2 core (having exprassive as a middleware) Application + apigility as api.
Hi guys,
I got the same error. And when I try your solution @vrkansagara I got this error :
PHP Fatal error: Cannot redeclare assetic_init() (previously declared in /Users/lucas/Sites/booking/apigility/vendor/kriswallsmith/assetic/src/functions.php:24) in /Users/lucas/Sites/booking/booking/vendor/kriswallsmith/assetic/src/functions.php on line 30
Poke @ezimuel
Hi,
I fixed this issue with :
$symfonyApp = '/path/to/symfony/';
require_once $symfonyApp . '/app/bootstrap.php.cache'; // This line is important
require_once $symfonyApp . '/app/AppKernel.php';
$kernel = new \AppKernel('prod', true);
$kernel->loadClassCache();
$kernel->boot();
$this->doctrine = $kernel->getContainer()
->get('doctrine')
->getManager();
I am accessing the
http://apigility.local/post
where I have successfully added the ApiBlog module from this repository. and added Symfony application. file intoPostResource.php
under the __construct method as bellowBut still error showing.
I have tested that AppKernel.php is successfully called into the __construct but while accessing the api get request
http://apigility.local/post
thowring the errors as bellow.