Container extension "framework" is not registered

Website URL

[(please specify the URL of the site on which you are experiencing the problem)](https://job-tracking.free.nf/)

Error Message

Container extension “framework” is not registered.

Other Information

Bonjour à tous, voilà 24h que je m’arrache la tête sur ce bug.

Mon appli est faite sur Symfony, elle a eu fonctionnée sur infityfree sur la même url avec les mêmes .htaccess.

Suite à un énième upload ce message m’est apparu, pensant que le problème venait des fichiers je les tous inspectés et Ras.

Je suis passé en prod en local, ça fonctionne. J’étais sur PHP 8.3, pensant à un pb de compatibilité j’ai downgradé sur PHP 8.2.24 : idem

Inspirer par chat gpt j’ai créé un nouveau projet Symfony (symfony new), j’ai tout supprimé sauf le .htaccess et j’ai le même probleme.

Au cas ou je vous laisse mon htaccess situé dasn htdocs :

# Désactiver les erreurs PHP en production
php_value display_errors On
php_value mbstring.http_input auto
php_value date.timezone Europe/Paris

# Activer le moteur de réécriture
RewriteEngine On

# Forcer HTTPS (optionnel)
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Si le fichier ou le dossier demandé existe, ne pas rediriger
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rediriger toutes les requêtes vers /public
RewriteRule ^(.*)$ /public/$1 [L]

# Rediriger tout vers public/index.php si fichier non trouvé
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /public/index.php [L]

Merci de votre aide.

Bien sûr j’ai vidé les caches et relancé composer install

Hi and welcome to the forum! Please note that this is an English-speaking forum and so you must speak in English or at least provide an accurate translation of what you wrote. Since you didn’t do that I’m going to translate what you wrote for you:

I don’t know if I can help too much because I don’t use Symfony, but after a simple search I found this:

3 Likes

Merci beaucoup, pour la réponse je ne me sens plus seul au monde :smiley: voici mon composer.yaml

{
    "type": "project",
    "license": "proprietary",
    "minimum-stability": "stable",
    "prefer-stable": true,
    "require": {
        "php": ">=8",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "doctrine/dbal": "^3",
        "doctrine/doctrine-bundle": "^2.13",
        "doctrine/doctrine-migrations-bundle": "^3.3",
        "doctrine/orm": "^3.2",
        "guzzlehttp/guzzle": "^7.9",
        "phpdocumentor/reflection-docblock": "^5.4",
        "phpstan/phpdoc-parser": "^1.30",
        "smalot/pdfparser": "^2.11",
        "symfony/apache-pack": "^1.0",
        "symfony/asset": "7.1.*",
        "symfony/asset-mapper": "7.1.*",
        "symfony/console": "7.1.*",
        "symfony/doctrine-messenger": "7.1.*",
        "symfony/dotenv": "7.1.*",
        "symfony/expression-language": "7.1.*",
        "symfony/flex": "^2",
        "symfony/form": "7.1.*",
        "symfony/framework-bundle": "7.1.*",
        "symfony/http-client": "7.1.*",
        "symfony/intl": "7.1.*",
        "symfony/mailer": "7.1.*",
        "symfony/mime": "7.1.*",
        "symfony/monolog-bundle": "^3.0",
        "symfony/notifier": "7.1.*",
        "symfony/process": "7.1.*",
        "symfony/property-access": "7.1.*",
        "symfony/property-info": "7.1.*",
        "symfony/runtime": "7.1.*",
        "symfony/security-bundle": "7.1.*",
        "symfony/serializer": "7.1.*",
        "symfony/stimulus-bundle": "^2.19",
        "symfony/string": "7.1.*",
        "symfony/translation": "7.1.*",
        "symfony/twig-bundle": "7.1.*",
        "symfony/ux-turbo": "^2.19",
        "symfony/validator": "7.1.*",
        "symfony/web-link": "7.1.*",
        "symfony/webpack-encore-bundle": "^2.1",
        "symfony/yaml": "7.1.*",
        "twig/extra-bundle": "^2.12|^3.0",
        "twig/twig": "^2.12|^3.0",
        "vich/uploader-bundle": "^2.4"
    },
    "config": {
        "allow-plugins": {
            "php-http/discovery": true,
            "symfony/flex": true,
            "symfony/runtime": true
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*",
        "symfony/polyfill-php73": "*",
        "symfony/polyfill-php74": "*",
        "symfony/polyfill-php80": "*",
        "symfony/polyfill-php81": "*",
        "symfony/polyfill-php82": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd",
            "importmap:install": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "7.1.*",
            "docker": true
        }
    },
    "require-dev": {
        "doctrine/doctrine-fixtures-bundle": "^3.6",
        "fakerphp/faker": "^1.23",
        "phpunit/phpunit": "^9.5",
        "symfony/browser-kit": "7.1.*",
        "symfony/css-selector": "7.1.*",
        "symfony/debug-bundle": "7.1.*",
        "symfony/maker-bundle": "^1.0",
        "symfony/phpunit-bridge": "^7.1",
        "symfony/stopwatch": "7.1.*",
        "symfony/web-profiler-bundle": "7.1.*"
    }
}

pour vider les caches je supprime directement le dossier cache.

PS : j’avais déjà vu cette réponse ainsi que Container extension "framework" is not registered · Issue #25618 · symfony/symfony · GitHub, et Compiling the Container (Symfony Docs). et bundle.php :

<?php

return [
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
    Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
    Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true],
    Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
    Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
    Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true],
    Symfony\UX\Turbo\TurboBundle::class => ['all' => true],
    Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
    Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
    Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
    Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
    Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
    Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
    Vich\UploaderBundle\VichUploaderBundle::class => ['all' => true],
];

Oups, i didn’t see that it is an english spoken forum for next post i’ll translate sorry.

After several investigations, I think the problem comes from my .htaccess file. What do you think?`# Désactiver les erreurs PHP en production
php_value display_errors On
php_value mbstring.http_input auto
php_value date.timezone Europe/Paris

Activer le moteur de réécriture

RewriteEngine On

Forcer HTTPS (optionnel)

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Si le fichier ou le dossier demandé existe, ne pas rediriger

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

Rediriger toutes les requêtes vers /public

RewriteRule ^(.*)$ /public/$1 [L]

Rediriger tout vers public/index.php si fichier non trouvé

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /public/index.php [L]
`

# Désactiver les erreurs PHP en production
php_value display_errors On
php_value mbstring.http_input auto
php_value date.timezone Europe/Paris

# Activer le moteur de réécriture
RewriteEngine On


# Forcer HTTPS (optionnel)
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Si le fichier ou le dossier demandé existe, ne pas rediriger
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rediriger toutes les requêtes vers /public
RewriteRule ^(.*)$ /public/$1 [L]

# Rediriger tout vers public/index.php si fichier non trouvé
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /public/index.php [L]

Eureka!!! It was my fault. After uploading, deleting, and re-uploading so many times, I had lost the Symfony .htaccess file from the /public folder, so it couldn’t work :ghost: :rage:. Here’s the .htaccess file to place in the public folder, just in case.

# Use the front controller as index file. It serves as a fallback solution when
# every other rewrite/redirect fails (e.g. in an aliased environment without
# mod_rewrite). Additionally, this reduces the matching process for the
# start page (path "/") because otherwise Apache will apply the rewriting rules
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex index.php

# By default, Apache does not evaluate symbolic links if you did not enable this
# feature in your server configuration. Uncomment the following line if you
# install assets as symlinks or if you experience problems related to symlinks
# when compiling LESS/Sass/CoffeScript assets.
# Options +SymLinksIfOwnerMatch

# Disabling MultiViews prevents unwanted negotiation, e.g. "/index" should not resolve
# to the front controller "/index.php" but be rewritten to "/index.php/index".
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

<IfModule mod_rewrite.c>
    # This Option needs to be enabled for RewriteRule, otherwise it will show an error like
    # 'Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden'
    Options +SymLinksIfOwnerMatch

    RewriteEngine On

    # Determine the RewriteBase automatically and set it as environment variable.
    # If you are using Apache aliases to do mass virtual hosting or installed the
    # project in a subdirectory, the base path will be prepended to allow proper
    # resolution of the index.php file and to redirect to the correct URI. It will
    # work in environments without path prefix as well, providing a safe, one-size
    # fits all solution. But as you do not need it in this case, you can comment
    # the following 2 lines to eliminate the overhead.
    RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::\2$
    RewriteRule .* - [E=BASE:%1]

    # Sets the HTTP_AUTHORIZATION header removed by Apache
    RewriteCond %{HTTP:Authorization} .+
    RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]

    # Redirect to URI without front controller to prevent duplicate content
    # (with and without `/index.php`). Only do this redirect on the initial
    # rewrite by Apache and not on subsequent cycles. Otherwise we would get an
    # endless redirect loop (request -> rewrite to front controller ->
    # redirect -> request -> ...).
    # So in case you get a "too many redirects" error or you always get redirected
    # to the start page because your Apache does not expose the REDIRECT_STATUS
    # environment variable, you have 2 choices:
    # - disable this feature by commenting the following 2 lines or
    # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
    #   following RewriteCond (best solution)
    RewriteCond %{ENV:REDIRECT_STATUS} =""
    RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]

    # If the requested filename exists, simply serve it.
    # We only want to let Apache serve files and not directories.
    # Rewrite all other queries to the front controller.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        # When mod_rewrite is not available, we instruct a temporary redirect of
        # the start page to the front controller explicitly so that the website
        # and the generated links can still be used.
        RedirectMatch 307 ^/$ /index.php/
        # RedirectTemp cannot be used instead
    </IfModule>
</IfModule>

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.