Namespaces for “Magento\\Framework\\”, “Magento\\” and physical directory structure

magento.stackexchange https://magento.stackexchange.com/questions/173268

  •  08-10-2020
  •  | 
  •  

Question

I have a custom class 'class ProductsList extends\Magento\CatalogWidget\Block\Product\ProductsList' and wonder where is the physical file containing the class?

Looking at the top level composer file, I see

    "autoload": {
    "psr-4": {
        "Magento\\Framework\\": "lib/internal/Magento/Framework/",
        "Magento\\Setup\\": "setup/src/Magento/Setup/",
        "Magento\\": "app/code/Magento/"
    }

... but when I look in the 'lib/internal' directory, there's no 'Magento/Framework'. Same goes for "Magento\": "app/code/Magento/"

What I do see in the project directory structure is 'vendor/magento/framework'

I looked at the project structure of Magento in GitHub at https://github.com/magento/magento2/tree/develop/lib/internal/Magento/Framework and there's the directory mapping I expected.

I'm trying to make sense of what I think the composer file is telling me and why the physical directory structure is not what I expect it to be.

PS: new to both php and Magento

Was it helpful?

Solution

class ProductsList extends\Magento\CatalogWidget\Block\Product\ProductsList

this would tell you exactly where it lies.

class ProductList - File ProductList.php in your custom module placed at app/code/NameSpace/ModuleName/Block

extends \Magento\CatalogWidget\Block\Product\ProductsList - this particular class can be found in a file placed at vendor/magento/module-catalog-widget/Block/Product/ProductList.php

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top