CakeDC / cakephp-api

API Plugin for CakePHP
Other
61 stars 33 forks source link

Extension CorsExtension could not be found... #27

Closed jeffreyroberts closed 7 years ago

jeffreyroberts commented 7 years ago
"status": "error",
"message": "Extension class CorsExtension could not be found. on line 73 in \/Users\/jlroberts\/Projects\/JeffreyLRobertsCom\/CakePHPKitchen\/AdminLTE\/vendor\/cakedc\/cakephp-api\/src\/Service\/ExtensionRegistry.php",
"code": 500,
"data": null,
"trace": [
    {
        "file": "\/Users\/jlroberts\/Projects\/JeffreyLRobertsCom\/CakePHPKitchen\/AdminLTE\/vendor\/cakephp\/cakephp\/src\/Core\/ObjectRegistry.php",
        "line": 91,
        "function": "_throwMissingClassError",
        "class": "CakeDC\\Api\\Service\\ExtensionRegistry"
    },
    {
        "file": "\/Users\/jlroberts\/Projects\/JeffreyLRobertsCom\/CakePHPKitchen\/AdminLTE\/vendor\/cakedc\/cakephp-api\/src\/Service\/Service.php",
        "line": 729,
        "function": "load",
        "class": "Cake\\Core\\ObjectRegistry"
    },
jeffreyroberts commented 7 years ago

I tried to put a die in the ExtensionRegistry in _resolveClassName, but it doesnt die, so im a bit at a loss right now

jeffreyroberts commented 7 years ago

CakeDC API Issue #27

Steps to reproduce locally....

#!/bin/bash
git clone https://github.com/CakePHPKitchen/CakeDC-API-Issue-27.git
cd CakeDC-API-Issue-27
composer install
bin/cake server -p 9001

Then navigate to

http://localhost:9001/api/foo/stats
jeffreyroberts commented 7 years ago

Figured out why my die wasn't working, looks like there is 2 ExtensionRegistry.php files, almost identical...

I see there are two Extension folders as well, what I don't see is why one extension registry would be picked over another, and its picking the wrong one...

jeffreyroberts commented 7 years ago

ok so I found the offending method, its in this method where we will decide to run

CakeDC\Api\Service\ExtensionRegistry

or

CakeDC\Api\Service\Action\ExtensionRegistry

Here is the method

public function extensions($extensions = null)
{
    if ($extensions === null && $this->_extensions === null) {
        $this->_extensions = new ExtensionRegistry($this);
    }
    if ($extensions !== null) {
        $this->_extensions = $extensions;
    }

    return $this->_extensions;
}
rogerpro commented 7 years ago

Closed per #28