Download the PHP package purc/autoloader-class-map without Composer

On this page you can find all versions of the php package purc/autoloader-class-map. 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 autoloader-class-map

AutoloaderClassMap

A PHP based class map generator and autoloader for usage with composer or directly in PHP projects.

Is able to parse several defined directories/files for existing class/interface/trait definitions and to generate a class map configuration file which is usable for an autoloader implementation.


Installation

Install using composer

NOTE: You may need to update your minimum-stability definition to dev in your composer.json in order to install this package.

Install via git clone

Open your command line tool, clone the repository, change to the directory, and run composer.

Download from GitHub with bash

Open bash, download the latest version (see the latest tag) from GitHub, extract the archive, change to the directory, and run composer.

Manually download from GitHub

Download the zip package from GitHub and extract it to a folder.

Open your command line tool, change to the extracted folder and run composer.


Description

Loading required class/interface/trait files, in PHP can be done via different ways.

A project should ideally use the autoloading standard as defined in the PSR-4, but this is not possible in some cases, e.g. when you have to deal with legacy code, which was implemented way before the existence of the PHP Standard Recommendation (PSR).

If the project is not PSR-4 compatible and/or there is no way to map automatically required class/interface/trait names to file system location, and you want to get rid of all require/include statements in your PHP files, then using a class map configuration is probably the convenient solution.

The AutoloaderClassMap parses specific folders for class, interface, and trait definitions, and generates a class map file from the parse results. The class map file can be used with a custom autoloader implementation, which deals with loading the required source files, the first time you use one of the class, interface or trait names in your PHP scripts.


Class Map Generator Options

There a some options to control class map creation described as follows:

excludeDirs

(string[]) List of directories to ignore (note: is case-insensitive)

Default value is ['.svn', '.cvs'].

excludeFiles

(string[]) List of files to ignore, regexp pattern is also accepted (note: is case insensitive)

Default value is ['/^~*.\.php$/', '/^~*.\.inc$/']

extensionsToParse

(string[]) List of file extensions to parse (note: is case-insensitive)

Default value is ['.php', '.inc']

enableDebug

(bool) Flag to enable debugging, collects some helpful state information's

Default value is false


Setting an Environment Variable or PHP $GLOBAL

The AutoloaderClassMap comes with a build-in Autoloader implementation, see Autoloader.php.

You need to define the path to your class map file in order to use the build-in Autoloader. This can be done by defining an environment variable or by setting the PHP superglobal $GLOBAL variable.

Environment Variable

There are different ways to set an environment variable, use the solution which fits the best for your needs.

  1. Setting the environment variable in a .env file, in case your project supports dotenv.

  2. Setting the environment variable in a .htaccess file, in case your project is served via Apache.

  3. Setting the environment variable in a PHP script, e.g. at the beginning of the application bootstrap process. This must be done before using an entry defined in the class map file!

PHP superglobal $GLOBAL Variable

The preferred way should be the setting of an environment variable, but it is also possible to set it via the PHP superglobal $GLOBAL.

Define the path to the class map file by setting the PHP superglobal $GLOBAL in a PHP script, e.g. at the beginning of the application bootstrap process. This must be done before using an entry defined in the class map file!


Usage

The AutoloaderClassMap examples will be within the vendor folder (vendor/purc/autoloader-class-map/examples) in case you have installed the package via composer.

You should copy the examples folder to you project root, by typing following command in you command line tool:

This step ist not mandatory, but most likely you need to do some adaptions in the example files, e.g. configuring the class map creation to your needs, and it is not recommended to modify files within the vendor folder. You can also use the logic in class_map_generation.php as a blueprint and implement your own class map creation script.

The description below will assume, that the examples folder is in your project root, and you are using the example files being delivered with the AutoloaderClassMap package.

Create a class map configuration

See examples folder.

Configure the example to your requirements and run the script from the command line as follows:

It should generate the class map configuration file classmap.configuration.php in same/configured directory.

Use the created class map configuration with an autoloader

You can use the build-in Autoloader implementation (see Autoloader.php) or set up your own.

See the section Setting an Environment Variable or PHP $GLOBAL above for using the build-in Autoloader.

In composer.json

By defining an autoload setting in your composer.json. The values in files will be loaded by composer's autoloading mechanism.

In a PHP Script

Require the autoloader script in PHP, e.g. at the beginning of the application bootstrap process. This must be done before using an entry defined in the class map file!


All versions of autoloader-class-map with dependencies

PHP Build Version
Package Version
Requires php Version >=7.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 purc/autoloader-class-map contains the following files

Loading the files please wait ....