Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8647871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:10:46+00:00 2026-06-12T13:10:46+00:00

I am trying to override the core Symfony components with my own. The method

  • 0

I am trying to override the core Symfony components with my own. The method I am using is:

"autoload": {
    "psr-0": { 
                "": "src/",
                "Symfony": "src/vendor/symfony/src/"
             }
}

However when I run composer update and install it never seems to take this into account. Is this not the correct method to force the autoloader to look into another directory first before the Symfony core?

Any pointers appreciated!

EDIT: Paths to files

src/vendor/symfony/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php

src/vendor/symfony/src/Symfony/Component/Translation/Translator.php
src/vendor/symfony/src/Symfony/Component/Translation/Loader/YamlFileLoader.php

<?php

// autoload_namespaces.php generated by Composer

$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);

return array(
    'Twig_Extensions_' => $vendorDir . '/twig/extensions/lib/',
    'Twig_' => $vendorDir . '/twig/twig/lib/',
    'Symfony\\Bundle\\SwiftmailerBundle' => $vendorDir . '/symfony/swiftmailer-bundle/',
    'Symfony\\Bundle\\MonologBundle' => $vendorDir . '/symfony/monolog-bundle/',
    'Symfony\\Bundle\\AsseticBundle' => $vendorDir . '/symfony/assetic-bundle/',
    'Symfony' => array($vendorDir . '/symfony/symfony/src/', '/src/vendor/symfony/src/'),
    'SessionHandlerInterface' => $vendorDir . '/symfony/symfony/src/Symfony/Component/HttpFoundation/Resources/stubs',
    'Sensio\\Bundle\\GeneratorBundle' => $vendorDir . '/sensio/generator-bundle/',
    'Sensio\\Bundle\\FrameworkExtraBundle' => $vendorDir . '/sensio/framework-extra-bundle/',
    'Sensio\\Bundle\\DistributionBundle' => $vendorDir . '/sensio/distribution-bundle/',
    'Monolog' => $vendorDir . '/monolog/monolog/src/',
    'Metadata\\' => $vendorDir . '/jms/metadata/src/',
    'JMS\\SecurityExtraBundle' => $vendorDir . '/jms/security-extra-bundle/',
    'JMS\\DiExtraBundle' => $vendorDir . '/jms/di-extra-bundle/',
    'JMS\\AopBundle' => $vendorDir . '/jms/aop-bundle/',
    'Doctrine\\ORM' => $vendorDir . '/doctrine/orm/lib/',
    'Doctrine\\DBAL' => $vendorDir . '/doctrine/dbal/lib/',
    'Doctrine\\Common' => $vendorDir . '/doctrine/common/lib/',
    'Doctrine\\Bundle\\DoctrineBundle' => $vendorDir . '/doctrine/doctrine-bundle/',
    'CG\\' => $vendorDir . '/jms/cg/src/',
    'Assetic' => $vendorDir . '/kriswallsmith/assetic/src/',
    '' => $baseDir . '/src/',
);

If I manually edit the autoload line to:

'Symfony' => array('/Users/macbook/Sites/Opia/Gaia/src/vendor/symfony/src/', $vendorDir . '/symfony/symfony/src/'),

Everything works as it is meant to. So now it is basically finding the solution to why composer does not compose properly.

EDIT 2:

Doing some more searching it appears the above method is not a good implementation:

https://groups.google.com/forum/#!msg/composer-dev/HprRV_wJZg4/M_zQ8O7lB6IJ

Instead I need to extend the given classes and tell Symfony to use those classes instead which should be possible through the parameters:

parameters: 
security.authentication.listener.anonymous.class: Acme\DemoBundle 
\Security\Http\Firewall\AcmeAnonymousAuthenticationListener

However I am not sure what parameters I need to set to load the extended classes in place of the core.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:10:47+00:00Added an answer on June 12, 2026 at 1:10 pm

    I finally found the answer to this.

    Firstly if you need to find out which classes to override go to:

    symfony/src/Symfony/Bundle/FrameworkBundle/Resources/%Your file to override%.xml
    

    There you will find a list of possible Symfony classes that can be extended/overridden.

    Then in your config.yml add (I chose to put mine in an extend namespace):

    parameters:
      twig.extension.trans.class: Extend\Symfony\Bridge\Twig\Extension\TranslationExtension
      translation.loader.yml.class: Extend\Symfony\Component\Translation\Loader\YamlFileLoader
      translator.class: Extend\Symfony\Bundle\FrameworkBundle\Translation\Translator
    

    Finally in my composer.json:

    "autoload": {
        "psr-0": { 
                    "": "src/",
                    "Extend\\Symfony": "/path/to/your/symfony/classes"
                 }
    },
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to override a method inside a jquery widget. The method can be
I'm trying to overwrite a core Wordpress function (found in media.php) using add_filter() in
I'm trying to override the method 'send_confirmation_instructions' as shown here: http://trackingrails.com/posts/devise-send-confirmation-mail-manually-or-delay-them with: def send_confirmation_instructions
I am trying to setup Phalanger to run on a remote IIS using the
What I was trying to do was to override the save method of one
I am trying to override the DataGridViewTextBoxCell's paint method in a derived class so
I am trying to override a core module on the Magento Platform. This is
I have been trying to override the database method of the loader class (CI_Loader).
When trying to override a base class method, I'm now getting an error as
Trying to override a tostring in one of my classes. return string.Format(@ name =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.