Download the PHP package baraja-core/class-map-generator without Composer

On this page you can find all versions of the php package baraja-core/class-map-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package class-map-generator

PHP Class Map Generator

Integrity check

A lightweight PHP library for scanning directories and generating a complete map of all PHP classes, interfaces, and traits with their corresponding file paths.

🎯 Key Features

πŸ—οΈ Architecture

The library consists of a single, focused class that handles all scanning and parsing logic:

How It Works

  1. Directory Iteration: The createMap() method uses RecursiveDirectoryIterator to traverse all files in the specified directory and its subdirectories.

  2. File Filtering: Only files with the .php extension are processed, skipping all other file types.

  3. Token Parsing: Each PHP file is read and parsed using PHP's token_get_all() function, which breaks down the source code into tokens.

  4. Namespace Detection: The parser tracks T_NAMESPACE tokens to build the current namespace context for class resolution.

  5. Class Detection: When T_CLASS, T_INTERFACE, or T_TRAIT tokens are encountered, the parser extracts the class name and combines it with the current namespace.

  6. ::class Constant Handling: The parser intelligently skips ::class constant usage (e.g., SomeClass::class) to avoid false positives.

  7. Memory Management: After processing each file, gc_mem_caches() is called to address a known PHP memory issue with token_get_all().

πŸ“¦ Installation

It's best to use Composer for installation, and you can also find the package on Packagist and GitHub.

To install, simply use the command:

You can use the package manually by creating an instance of the internal classes, or register a DIC extension to link the services directly to the Nette Framework.

Requirements

πŸš€ Usage

Basic Usage

Generate a class map for a directory:

Return Value

The createMap() method returns an associative array where:

Practical Examples

Finding a Specific Class File

Listing All Classes in a Namespace

Building an Autoloader

Caching the Class Map

For performance optimization in production environments:

Scanning Multiple Directories

πŸ” What Gets Detected

The library detects the following PHP constructs:

Construct Detected Example
Classes Yes class MyClass {}
Abstract classes Yes abstract class BaseController {}
Final classes Yes final class ImmutableValue {}
Interfaces Yes interface PaymentGateway {}
Traits Yes trait Loggable {}
Anonymous classes No new class {}
Enums No enum Status {}

⚠️ Limitations

πŸ”§ Technical Notes

Memory Management

The library calls gc_mem_caches() after processing each file to address a known PHP memory issue where token_get_all() doesn't release memory properly. This ensures stable memory usage when scanning large codebases.

Path Resolution

The library attempts to get the real path of each file using getRealPath(). If this fails (e.g., on some edge cases with symlinks), it falls back to getPathname().

Inspiration

This library is based on the Symfony ClassLoader component, adapted and modernized for PHP 8.0+ with strict typing and simplified API.

πŸ‘¨β€πŸ’» Author

Jan BarΓ‘Ε‘ek - https://baraja.cz

πŸ“„ License

baraja-core/class-map-generator is licensed under the MIT license. See the LICENSE file for more details.


All versions of class-map-generator with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package baraja-core/class-map-generator contains the following files

Loading the files please wait ...