PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, January 22, 2022

[FIXED] Is it possibile to get all classes present inside a composer project?

 January 22, 2022     composer-php     No comments   

Issue

I need to get all classes that are present inside a folder and its subfolder. For example, with this tree

src/
├── Foo
│   └── Bar
│       └── Hello.php
└── Hello
    └── World.php

I would get a list of classes like:

Foo\Bar\Hello
Hello\World

Can composer be used to get this kind of list? Or, ... exists a way to get the list of all classes present inside a folder(src folder)?


Solution

First of all, you should run command:

composer dump-autoload --optimize

Next you could try this code:

$classMap = array_keys(require('vendor/composer/autoload_classmap.php));


Answered By - VirCom
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing