ECOMMERCEMagento DevelopmentMagento 2 MigrationOdoo ERPOdoo ERP MigrationCRM for CommerceLAMP TECHNOLOGYPHP Website DevelopmentLaravel DevelopmentWordPress DevelopmentSymfony DevelopmentProgressive Web AppsMOBILEiPhone App DevelopmentAndroid App DevelopmentHybrid App DevelopmentMobile CommerceXamarin App DevelopmentNODE.JS & MONGODBFull Stack DevelopmentMEAN StackAngularJS & ReactJSNode.JS DevelopmentReact Native DevelopmentMICROSOFTASP.NET DevelopmentASP.NET Core DevelopmentSharePoint DevelopmentPowerBI DevelopmentArtificial Intelligence/MLCLOUD SERVICESDevOpsAmazon Web ServicesAzure Cloud ServiceGoogle App Engine ServicesPowerApps & Office 365ENTERPRISE SERVICESAugmented RealityCRMEnterprise Mobility ServicesBlockchain ServicesData AnalyticsDIGITAL MARKETINGSearch Engine OptimizationPaid AdvertisingSocial Media MarketingSEO for eCommerceContent MarketingRetailReal EstateEducationFinanceHealthcareMedia & EntertainmentLogisticsAdvertisingDiamond and JewelryAutomotiveMobile and WirelessCloud ServicesGamingIOTBlockchainRetail Omni Channel ERPAuro CRMMulti Vendor MarketplaceBvPOS SystemFacebook BotManaged Analytics- EzlytixPowerBI Managed AnalyticsDiamond ERPUniversity Management- MantisDigital Asset Profanity- eUnagiHRMSCash in TransitALM with TFSABOUT USFactsheetAbout BrainvireHistoryExecutive LeadershipCore ValuesLife @ BrainvireOur ClientsClient TestimonialsClient’s Video TestimonialsClutch Testimonials

How to Find Duplicate Classes In Symfony

Sometimes, Symfony presents unique problems with classes being silently redeclared. So much so that you might think that you are making changes to one file but your changes don’t have any effect.
Declaring a class in two separate files with that have the same filename, results in Symfony (Or similar frameworks) that have an autoloader to load only the first file that it gets to.

This is used by some Symfony programmers intentionally to override a class on purpose. For example, in a third party plugin where you cannot control the original class and it’s a challenge or it’s impossible to extend the third party plug in. That’s how this can be beneficial, but when you do not want to override it, it poses a challenge.

It can cause obstructions in a lot of situations. When you are deploying over a legacy FTP connection or rsync or gross, you might just end up with the same file in two different locations. Moving classes between deployments might end up loading classes twice and in two locations. Well, unless the entire code is removed from remote server, you will never realize that just one file is being used.

In large projects however, it sometimes happens that a class file gets duplicated and no one notices. Take for example, there are three developers working on similar platforms as well as PHP versions. They make changes to the class file that they perceive as “right” which turns out to be the file you expected to be loaded – not the duplicate one that people apparently forgot about. The duplicate file goes unnoticed by all developers – until some subtle differences in system configuration changes the order of the autoloaded files.
Here’s how your PHP class files should be named:
With this, you can run a report of duplicate class names
find . -name '*.class.php' | xargs basename | sort | uniq –d
or in Mac OS, taking advantage of the native indexing:
mdfind -onlyin . -name '.class.php -actions.class.php -components.class.php' | xargs basename | sort | uniq –d
After that, you can check each class for duplicate classes and determine which one you actually want to use and easily eliminate the ones that you know you aren’t going to use.

In search for strategic sessions?
Let us understand your business thoroughly and help you strategies your digital product..
Book a session
Rate Us!
5.00/5 (295)