404 not found for API routes


(Alexander) #1

Hi, I’m trying to bring to life locally a project created by another dev, I’m running Xampp 5.6.28 over Mac.

Currently the project is serving the backend and frontend urls but the api routes throw 404 Not Found errors.

Apache conf is:


<Directory "/Applications/XAMPP/xamppfiles/htdocs">

    # use mod_rewrite for pretty URL support

    RewriteEngine on

    # If a directory or a file exists, use the request directly

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    # Otherwise forward the request to index.php

    RewriteRule . index.php


    # XAMPP

    Options Indexes FollowSymLinks ExecCGI Includes


    #

    # AllowOverride controls what directives may be placed in .htaccess files.

    # It can be "All", "None", or any combination of the keywords:

    #   Options FileInfo AuthConfig Limit

    #

    #AllowOverride None

    # since XAMPP 1.4:

    AllowOverride All


    #

    # Controls who can get stuff from this server.

    #

    Require all granted

</Directory>

The app follows the "Yii 2 Advanced Project Template" structure, the api is in:

app/api/ and the controllers that should be responding are at: app/api/modules/v1/controllers/AppController.php

There’s an api/config/main.php with this:


<?php

$params = array_merge(

    require(__DIR__ . '/../../common/config/params.php'),

    require(__DIR__ . '/../../common/config/params-local.php'),

    require(__DIR__ . '/params.php'),

    require(__DIR__ . '/params-local.php')

);


return [

    'id' => 'app-api',

    'basePath' => dirname(__DIR__),

    'controllerNamespace' => 'api\controllers',

    'defaultRoute'=>'default',

    'bootstrap' => ['log'],

    'modules' => [

        'v1' => [

            'class' => 'api\modules\v1\Module',

        ],

    ],

    'components' => [

        'user' => [

            'identityClass' => 'common\models\User',

            'enableAutoLogin' => false,

        ],

        'log' => [

            'traceLevel' => YII_DEBUG ? 3 : 0,

            'targets' => [

                [

                    'class' => 'yii\log\FileTarget',

                    'levels' => ['error', 'warning'],

                ],

            ],

        ],

        'request' => [

        	'enableCsrfValidation'=>false,

        	'parsers' => [

        		'application/json' => 'yii\web\JsonParser',

        	]

        ],

        'errorHandler' => [

       		'errorAction' => 'default/error',

        ],

        'urlManager'=>[

	        'enablePrettyUrl'=>true,

	        'showScriptName'=>false,

        ],

    ],

    'params' => $params,

];

And a common/config/main.php with:


<?php

return [

    'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',

    'name' => 'FULOOP',

    'components' => [

        'cache' => [

            'class' => 'yii\caching\FileCache',

        ],

        'authManager' => [

        	'class' => 'yii\rbac\DbManager',

        ],

        'formatter' => [

	        'class' => 'yii\i18n\Formatter',

	        'dateFormat' => 'php:m/d/Y',

	        'datetimeFormat' => 'php:m/d/Y H:i:s',

	        'timeFormat' => 'php:H:i:s',

        ],		

		'frontendUrlManager'=>[

           'class' => 'yii\web\urlManager',

           'enablePrettyUrl'=>true,

           'showScriptName'=>false,

           'baseUrl'=>'/fuloop/frontend/web',

       ],

    ],

];

I’m not familiar with the Yii Framework so I’m not sure where exactly should I be looking for this,

thanks in advance for any help.