I have a messy web application writen in Symfony and Yii. stucture of application looks like:
|- app
| |- app
| |- src <code>
| | |-App
| |- protected <symfony fw>
| | |-vendor
| |- yii <yii fw>
| |- composer.json
| |- index.php
and index.php
require symfony.php
. and at that file, i new Kernel
class. and it locales inside src/App
. but when running, it throw code:
Attempted to load class "Kernel" from namespace "App". Did you forget a "use" statement for e.g. "Symfony\Component\HttpKernel\Kernel", "Illuminate\Contracts\Console\Kernel" or "Illuminate\Contracts\Http\Kernel"?
My symofony.php
<?php
require_once __DIR__ . '/../protected/vendor/autoload.php';
require_once __DIR__ . '/../protected/Application.php';
require_once __DIR__ . '/../protected/Environment.php';
use App\Kernel;
use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\HttpFoundation\Request;
require __DIR__ . '/config/bootstrap.php';
if ($_SERVER['APP_DEBUG']) {
umask(0000);
Debug::enable();
}
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
Request::setTrustedHosts([$trustedHosts]);
}
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
The class Kernel
is:
<?php
namespace App;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\RouteCollectionBuilder;
class Kernel extends BaseKernel
{
use MicroKernelTrait;
private const CONFIG_EXTS = '.{php,xml,yaml,yml}';
private $files;
My composer.json
at autoload:
"autoload": {
"psr-4": {
"SCO\\": "src/",
"App\\": "app/src/App/",
},
"classmap" : [
"protected/components/",
"protected/models/",
"protected/modules/"
],
},
you can see, namespace SCO
actually cover the App
in file directory view.
It work on my macbook (docker), but when i move to windows using xampp, it brokes