jdesrosiers / silex-json-schema-provider

A Silex service provider for working with JSON Schema
MIT License
5 stars 0 forks source link

Class not found error #1

Closed niabot closed 8 years ago

niabot commented 8 years ago

I just installed silex-json-schema-provider using composer and get the following error once i try to register the JsonSchemaServiceProvider with my silex application.

[Mon Jun 13 07:54:10.545816 2016] [:error] [pid 16200] [client 192.168.0.146:5761] PHP Fatal error:  Class 'JDesrosiers\\Silex\\Provider\\JsonSchemaServiceProvider' not found in /var/www/silex/asys/ShopApplication.php on line 92, referer: http://localhost:8383/ts-asysshop/dist/index.html
[Mon Jun 13 07:54:10.545869 2016] [:error] [pid 16200] [client 192.168.0.146:5761] PHP Stack trace:, referer: http://localhost:8383/ts-asysshop/dist/index.html
[Mon Jun 13 07:54:10.545892 2016] [:error] [pid 16200] [client 192.168.0.146:5761] PHP   1. {main}() /var/www/silex/web/index.php:0, referer: http://localhost:8383/ts-asysshop/dist/index.html
[Mon Jun 13 07:54:10.545909 2016] [:error] [pid 16200] [client 192.168.0.146:5761] PHP   2. asys\\ShopApplication->__construct() /var/www/silex/web/index.php:8, referer: http://localhost:8383/ts-asysshop/dist/index.html
[Mon Jun 13 07:54:10.545925 2016] [:error] [pid 16200] [client 192.168.0.146:5761] PHP   3. asys\\ShopApplication->initServices() /var/www/silex/asys/ShopApplication.php:37, referer: http://localhost:8383/ts-asysshop/dist/index.html

It basically tells me that autoload from composer isn't able to locate the class, because of some error inside the configuration of the class loader. But I'm not sure what is causing the issue. All other installed classes load just fine, even Jsv4. To get it running - for now - i copied your files (DescribedBy.php, JsonSchemaServiceProvider.php, Jsv4Validator.php) into my project and gave them a different namespace. Now JsonSchemaServiceProvider is found and works as intended.

ShopApplication.php

use Silex\Application;
use JDesrosiers\Silex\Provider\JsonSchemaServiceProvider;

class ShopApplication extends Application {
    function __construct() {
        $this->register(new JsonSchemaServiceProvider());
    }
    // ...
}

composer.json

{
    "require": {
        "silex/silex": "^2.0.0",
        "symfony/security": "^3.0.0",
        "doctrine/dbal": "^2.5.0",
        "jdesrosiers/silex-json-schema-provider": "~1.0"
    }
}

autoload_psr4.php

<?php

// autoload_psr4.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'Symfony\\Polyfill\\Util\\' => array($vendorDir . '/symfony/polyfill-util'),
    'Symfony\\Polyfill\\Php70\\' => array($vendorDir . '/symfony/polyfill-php70'),
    'Symfony\\Polyfill\\Php56\\' => array($vendorDir . '/symfony/polyfill-php56'),
    'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
    'Symfony\\Component\\Security\\' => array($vendorDir . '/symfony/security'),
    'Symfony\\Component\\Routing\\' => array($vendorDir . '/symfony/routing'),
    'Symfony\\Component\\PropertyAccess\\' => array($vendorDir . '/symfony/property-access'),
    'Symfony\\Component\\Inflector\\' => array($vendorDir . '/symfony/inflector'),
    'Symfony\\Component\\HttpKernel\\' => array($vendorDir . '/symfony/http-kernel'),
    'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'),
    'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
    'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'),
    'Silex\\' => array($vendorDir . '/silex/silex/src/Silex'),
    'JDesrosiers\\Silex\\Provider\\' => array($vendorDir . '/jdesrosiers/silex-json-schema-provider/src'),
    'Doctrine\\Common\\Cache\\' => array($vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache'),
    'Doctrine\\Common\\' => array($vendorDir . '/doctrine/common/lib/Doctrine/Common'),
);

installed.json (partially)

   {
        "name": "geraintluff/jsv4",
        "version": "v1.0.1",
        "version_normalized": "1.0.1.0",
        "source": {
            "type": "git",
            "url": "https://github.com/geraintluff/jsv4-php.git",
            "reference": "1d4306d39030aa288979d6822070777e4034722e"
        },
        "dist": {
            "type": "zip",
            "url": "https://api.github.com/repos/geraintluff/jsv4-php/zipball/1d4306d39030aa288979d6822070777e4034722e",
            "reference": "1d4306d39030aa288979d6822070777e4034722e",
            "shasum": ""
        },
        "time": "2014-10-07 13:36:26",
        "type": "library",
        "installation-source": "dist",
        "autoload": {
            "classmap": [
                "jsv4.php",
                "schema-store.php"
            ]
        },
        "notification-url": "https://packagist.org/downloads/",
        "license": [
            "MIT"
        ],
        "authors": [
            {
                "name": "Geraint Luff",
                "email": "luffgd@gmail.com"
            }
        ],
        "description": "A (coercive) JSON Schema v4 Validator for PHP",
        "keywords": [
            "Geraint Luff",
            "JSON Schema",
            "geraintluff",
            "json",
            "schema",
            "v4",
            "validator"
        ]
    },
    {
        "name": "jdesrosiers/silex-json-schema-provider",
        "version": "v1.0.0",
        "version_normalized": "1.0.0.0",
        "source": {
            "type": "git",
            "url": "https://github.com/jdesrosiers/silex-json-schema-provider.git",
            "reference": "efe3144ab74f35a51465205c163f15c782261741"
        },
        "dist": {
            "type": "zip",
            "url": "https://api.github.com/repos/jdesrosiers/silex-json-schema-provider/zipball/efe3144ab74f35a51465205c163f15c782261741",
            "reference": "efe3144ab74f35a51465205c163f15c782261741",
            "shasum": ""
        },
        "require": {
            "geraintluff/jsv4": "~1.0",
            "silex/silex": "~2.0"
        },
        "require-dev": {
            "phpunit/phpunit": "~4.5",
            "symfony/browser-kit": "~2.6"
        },
        "time": "2016-06-06 06:40:44",
        "type": "library",
        "installation-source": "dist",
        "autoload": {
            "psr-4": {
                "JDesrosiers\\Silex\\Provider\\": "src/"
            }
        },
        "notification-url": "https://packagist.org/downloads/",
        "license": [
            "MIT"
        ],
        "authors": [
            {
                "name": "Jason Desrosiers",
                "email": "jdesrosi@gmail.com"
            }
        ],
        "description": "A Silex service provider for working with JSON Schema",
        "keywords": [
            "JSON Hyper-Schema",
            "JSON Schema",
            "hyper-schema",
            "json",
            "json-schema",
            "jsv4",
            "silex"
        ]
    }
jdesrosiers commented 8 years ago

I'm not able to reproduce the problem. Everything seems to be working fine for me. Everything you posted looks like it should work. Even the autoload file looks correct. Maybe composer has something cached that is causing problems.

niabot commented 8 years ago

I wonder why, but after removing and reinstalling of all (!) dependencies it is now working as expected. Composer must have really done something wrong. My bad for the wrong report.