Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Add Zend\ServiceManager v3 compatibility #59

Merged
merged 2 commits into from
Jan 18, 2016

Conversation

mpalourdio
Copy link

Hello,
I wanted to give this skeleton a try. So I just did composer create-project zendframework/zend-expressive-skeleton but directly ran into the following error after install :

Fatal error: Uncaught TypeError: Argument 1 passed to Zend\ServiceManager\ServiceManager::__construct() must be of the type array, object given

I had chosen : FastRoute, Zend\ServiceManager and Twig as dependencies.

It appears that the installer made me download Zend\ServiceManager v3 as dependency. This PR fixes the config file to be compliant with v3, whose constructor expects an array to be injected.

@mpalourdio
Copy link
Author

I see the tests fail. I just tried a git clone && composer install and Zend\ServiceManager v 2.7.3 is downloaded as a dependency. I suppose that one of the packages retrieved by the interactive installer forces the v3 dependency.

@mpalourdio
Copy link
Author

Here is my generated composer.json

{
    "name": "zendframework/zend-expressive-skeleton",
    "type": "project",
    "homepage": "https://github.com/zendframework/zend-expressive-skeleton",
    "license": "BSD-3-CLAUSE",
    "authors": [
        {
            "name": "Geert Eltink",
            "homepage": "https://xtreamwayz.github.io/"
        }
    ],
    "require": {
        "roave/security-advisories": "dev-master",
        "zendframework/zend-expressive": "^0.5",
        "zendframework/zend-stdlib": "~2.7",
        "zendframework/zend-expressive-fastroute": "^0.1",
        "zendframework/zend-servicemanager": "^2.5",
        "ocramius/proxy-manager": "^1.0",
        "zendframework/zend-expressive-twigrenderer": "^0.1"
    },
    "require-dev": {
        "composer/composer": ">=1.0.0-alpha10",
        "phpunit/phpunit": "^4.8",
        "squizlabs/php_codesniffer": "^2.3",
        "filp/whoops": "^1.1"
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "AppTest\\": "test/"
        }
    },
    "scripts": {
        "test": [
            "php vendor/squizlabs/php_codesniffer/scripts/phpcs",
            "php vendor/phpunit/phpunit/phpunit"
        ]
    }
}
``

@mpalourdio
Copy link
Author

Last information, after using the installer, if I composer update, here is what I see :

Updating dependencies (including require-dev)
  - Removing zendframework/zend-expressive-template (1.0.1)
  - Removing zendframework/zend-expressive-router (1.1.0)
  - Removing zendframework/zend-expressive-fastroute (1.0.1)
  - Installing zendframework/zend-expressive-fastroute (0.1.2)
    Loading from cache

  - Removing zendframework/zend-expressive-twigrenderer (1.0.0)
  - Installing zendframework/zend-expressive-twigrenderer (0.1.1)
    Loading from cache

  - Removing zendframework/zend-servicemanager (3.0.0)
  - Installing zendframework/zend-servicemanager (2.7.3)
    Loading from cache

  - Removing filp/whoops (2.0.0)
  - Installing filp/whoops (1.1.10)
    Loading from cache ```

@weierophinney
Copy link
Member

The way to make it work with both v2 and v3 is to create a Zend\ServiceManager\Config instance with the dependency configuration, and then $config->configure($container), if you want to update this PR to work with either version.

I'm really not sure how you were getting the 3.0 version (the constraints should never install it), nor why an update is downgrading versions to pre-1.0 tags. Honestly, I suspect a subtle composer issue or stale composer cache.

@mpalourdio mpalourdio changed the title Return Zend\ServiceManager config as array to be v3 compliant Add Zend\ServiceManager v3 compatibility Jan 17, 2016
@mpalourdio
Copy link
Author

Thanks for you suggestion, I have updated this PR.

@weierophinney weierophinney added this to the 1.0.0rc6 milestone Jan 18, 2016
@weierophinney weierophinney self-assigned this Jan 18, 2016
@weierophinney weierophinney merged commit f1d26a3 into zendframework:master Jan 18, 2016
weierophinney added a commit that referenced this pull request Jan 18, 2016
Add Zend\ServiceManager v3 compatibility
weierophinney added a commit that referenced this pull request Jan 18, 2016
weierophinney added a commit that referenced this pull request Jan 18, 2016
weierophinney added a commit that referenced this pull request Jan 18, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants