Giter Site home page Giter Site logo

zf2-bridge's Issues

Cannot make PHP_DI is working with Zend2

Hi Matthieu,

Could you please give a hint why PHP-DI can be not working for me in integration with Zend2 (reproduced with Apache/2.4.9 (Win64) PHP/5.5.12 and Apache/2.2.22 (Win32) PHP/5.3.13).

composer.json

{
    "require": {
        "php": ">=5.3.3",
        "zendframework/zendframework": "2.3.5",
        "mnapoli/php-di": "4.4.6",
        "mnapoli/php-di-zf2": "0.3.0",
        ...
    },
    "autoload": {
        "classmap": [
            ...
        ],
        "psr-0": {
            "Morpho": "module/Morpho/src",
            "phpMorphy": "vendor/makhov/phpmorphy/src/common.php"
        }
    }
}

module/Morpho/config.module.config.php:

<?php
return array(
    'modules' => array(
        'DI\ZendFramework2',
    ),
    'router' => array(
        ...
        ),
    ),
    'controllers' => array(
        ...
    ),
    'view_manager' => array(
        ...
    ),
    'service_manager' => array(
        'factories' => array(
            'DI\Container' => function() {
                $builder = new DI\ContainerBuilder();
                $builder->addDefinitionsFromFile("config/di.yml");
                return $builder->build();
            },
        ),
    ),
);

config/di.yml:

Morpho\Service\PartOfSpeechService:
    class: Morpho\Service\PhpMorphyPartOfSpeechService

module/Morpho/src/Morpho/Controller/PartOfSpeechController:

class PartOfSpeechController extends AbstractRestfulController {
    ...
    /**
     * @Inject
     *
     * @var PartOfSpeechService
     */
    public $partOfSpeechService;

    public function processPostData(Request $request) {
        $partsOfSpeech = $this->partOfSpeechService->getPartsOfSpeech("test", "en_EN");
        return new JsonModel($partsOfSpeech);
    }

When running this code under apache each time I get:

PHP Fatal error:  Call to a member function getPartsOfSpeech() on a
non-object in \module\Morpho\src\Morpho\Controller\PartOfSpeechController.php on line 34

The injection is working normally if obtain the controller object using container but not under Zend2 MVC.
Any your thoughts would be really appreciated.

ZF3 support

When i try to to use error occured:

Fatal error: Class DI\ZendFramework2\Service\PHPDIAbstractFactory contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (Zend\ServiceManager\Factory\AbstractFactoryInterface::canCreate, Zend\ServiceManager\Factory\FactoryInterface::__invoke) in /home/sohorev/workspace/multivpn-php/vendor/php-di/zf2-bridge/src/DI/ZendFramework2/Service/PHPDIAbstractFactory.php on line 23

Why can not I use several projects in one memcached instance?

In README

If you're using Memcached, you should have only one project per memcached instance.

But i can use namespace:

return [
    'phpdi-zf2' => [
        'cache' => [
            'adapter' => 'memcached',
            'host' => 'localhost', // default is localhost
            'port' => 11211, // default is 11211
            'namespace' => 'my_second_project_',
        ],
    ]
];

ZF2 bridge Bug - Cache factory can not return null

Hi

DI\ZendFramework2\Service\Cache\CacheFactory in createService() method can return null, but ZF2 ServiceLocator does not allow this behaviour - you'll get this :

\Zend\ServiceManager\ServiceManager @ 953
if ($instance === null) {
            throw new Exception\ServiceNotCreatedException('The factory was called but did not return an instance.');
        }

ZF2 version Im using is current stable ("zendframework/zendframework": "~2.5").

Proposed fixes :
Add some 'BlackholeCache' as default service returned via DiCache factory
Or simple, but a little nasty - catch and handle ServiceNotCreatedException

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.