Api tool not working with existing MVC application

Hi, I’m not able to see laminas API tools within an existing application configured with apache2 as a web server. The problem I’m facing is the initialization of AssetManager and Laminas\DevelopmentMode. I’ve removed Laminas\DevelopmentMode to run my existing MVC application but for the asset manager, it gives an initialization error for the module. The routes of the API tool can be seen in the configuration but somehow it throws a 404 error. The composer.json file looks like the following.

        "php": "^7.3",
        "laminas/laminas-component-installer": "^1.0 || ^2.1",
        "laminas/laminas-development-mode": "^3.2",
        "laminas/laminas-mvc": "^3.1.1",
        "laminas/laminas-captcha": "^2.7",
        "laminas/laminas-recaptcha": "^3.2",
        "laminas/laminas-code": "^2.6 || ^3.0 || ^4.0",
        "laminas/laminas-serializer": "^2.9",
        "laminas/laminas-cache": "^2.10",
        "laminas/laminas-i18n-resources": "^2.6",
        "psr/http-message": "^1.0",
        "psr/http-factory": "^1.0",
        "san/san-session-toolbar": "^4.0",
        "doctrine/doctrine-orm-module": "^3.1.1",
        "lm-commons/lmc-user": "^3.1",
        "lm-commons/lmc-user-doctrine-orm": "^3.0",
        "lm-commons/lmc-rbac-mvc": "^3.0",
        "doctrine/doctrine-bundle": "^2.2",
        "laminas-commons/lmc-rbac-mvc": "^3.0",
        "gedmo/doctrine-extensions": "^3.0",
        "laminas/laminas-navigation": "^2.10",
        "doctrine/persistence": "^2.1",
        "lm-commons/lmc-admin": "^1.0",
       "laminas/laminas-mail": "^2.16",
        "doctrine/migrations": "^3.0.0",
        "laminas-api-tools/api-tools": "~1.4"
    },
    "autoload": {
        "psr-4": {
            "Application\\": "module/Application/src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "ApplicationTest\\": "module/Application/test/"
        }
    },
    "scripts": {
        "cs-check": "phpcs",
        "cs-fix": "phpcbf",
        "development-disable": "laminas-development-mode disable",
        "development-enable": "laminas-development-mode enable",
        "development-status": "laminas-development-mode status",
        "post-create-project-cmd": [
            "@development-enable",
            "php bin/update-gitignore.php",
            "php -r 'if (file_exists(\"bin/remove-package-artifacts.php\")) include \"bin/remove-package-artifacts.php\";'",
            "php -r 'if (file_exists(\"CHANGELOG.md\")) unlink(\"CHANGELOG.md\");'"
        ],
        "serve": "php -S 0.0.0.0:8080 -t public",
        "test": "phpunit"
    },
    "require-dev": {
        "laminas/laminas-developer-tools": "^2.1",
        "laminas/laminas-test": "^3.4",
        "laminas-api-tools/api-tools-admin": "~1.4",
        "laminas-api-tools/api-tools-asset-manager": "^1.5"
    },
    "config": {
        "allow-plugins": {
            "laminas/laminas-component-installer": false,
            "laminas-api-tools/api-tools-asset-manager": true
        }
    }

After the removal of AssetManager and Laminas/Development mode from the module config file. The below uri is accessible.

http://local.mylamians-expriment.com/api-tools/api/dashboard

My module configuration file.

return [
    'Laminas\Navigation',
    'Laminas\Db',
    'Laminas\I18n',
    'Laminas\Mvc\Plugin\FlashMessenger',
    'Laminas\Mvc\Plugin\Prg',
    'Laminas\Paginator',
    'Laminas\Cache',
    'Laminas\Serializer',
    'Laminas\Form',
    'Laminas\InputFilter',
    'Laminas\Filter',
    'Laminas\Session',
    'Laminas\Hydrator',
    'Laminas\Router',
    'Laminas\Validator',
    'DoctrineModule',
    'DoctrineORMModule',
    'LmcRbacMvc',
    'LmcUser',
    'LmcUserDoctrineORM',
    'LmcAdmin',
    'LRPHPT',
    'Application',
    // Laminas Api Tool modules
    'Laminas\ApiTools',
    'Laminas\ApiTools\Provider',
//     'AssetManager',
    'Laminas\ApiTools\ApiProblem',
    'Laminas\ApiTools\MvcAuth',
    'Laminas\ApiTools\OAuth2',
    'Laminas\ApiTools\Hal',
    'Laminas\ApiTools\ContentNegotiation',
    'Laminas\ApiTools\ContentValidation',
    'Laminas\ApiTools\Rest',
    'Laminas\ApiTools\Rpc',
    'Laminas\ApiTools\Versioning',
//     'Laminas\DevelopmentMode',
];

Thanks!

1 Like

Sorry, it was my mistake altogether. It works fine. The URL to access it with an existing application is this.
If you’ve configured a virtual host, it will be virtualhost/api-tools/ui#/. If you’re working with PHP webserver it will be localhost:8080/api-tools/ui#/.

Thanks!

Hi @ALTAMASH80,

I noticed that you have lmc-rbac-mvc twice in your composer JSON file.

Laminas-commons/lmc-rbac-mvc has been archived for a couple of years now.

Thanks, @visto9259! I’ll check that and see what else I’ve in my composer which has been archived.