Download the PHP package nastuzzi-samy/reflection-namespace without Composer

On this page you can find all versions of the php package nastuzzi-samy/reflection-namespace. 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 reflection-namespace

ReflectionNamespace class

Travis Build Issues Stars License

Introduction

Instead of searching all classes, sub directories in a specific directory, why can't you use their root namespace ?

Moreover, sometimes files within the same namespace are defined in different directories, multiple researches are needed here to get all of them.

PHP has by default multiple Reflector classes: class, parameters, constant, methods, etc. But no solutions exist to reflect a namespace. It could be usefull, now, as all projects use different packages via Composer.

The ReflectionNamespace class loads its data (sub namespaces, classes) from Composer. It uses PSR-0 (disabled by default), PSR-4, classmap and files autoloaders. It loads also from already declared classes, traits and interfaces (also disabled by default).

Installation

Simple installation via Composer:

composer install nastuzzi-samy/reflection-namespace

As it is working with the Composer engine (autoloaders), it needs to be implemented in a Composer project.

Usage

First of all, the ReflectionNamespace class is on the root namespace as the other Reflector classes.

Creation

To create a new ReflectionNamespace, you need to pass it the namespace you want to work on as a string:

Get information

As it is expensive, the ReflectionNamespace only loads classes and namespaces only when it is asked to. Mainly, you can use the class only to parse the short and long name of a namespace without carring about resource consumption.

Get classes and namespaces

By getting classes or namespaces, the ReflectionNamespace class will load every data, browsing all Composer autoloaders and in some case, if Composer did not cache all files/classes, search in directories (case for PSR-0 and PSR-4 only).

Of course, you can get a precise class or namespace with getClass and getNamespace. Or you can check if the namespace owns a class or a sub namespace with hasClass and hasNamespace.

Advanced usage

Enable loading from PSR-0

By default, PSR-0 loaders are not handled (as it is deprecated) and the reflection could lead to a uncompleted search. For that, to use PSR-0 loaders, you can enable the usage of it by calling the static method:

Enable loading from loaded classes, interfaces and traits

By default, loading all already declared classes, interfaces and traits is not handled and the reflection could lead to a uncompleted search. This is because it could be really expensive in a large project, using a lot of heavy packages. It is rarely usefull because usually, all declared classes are listed by Composer. For any reason, if you want to load all of them, you can enable the usage of it by calling the static method:

Manipulate loaders

You can get the based loaders with the static method: getLoaders. Loaders are common to all ReflectionNamespace objects.

As written in the test code tests/0-DefinitionTest.php, you can create your own autoloader in anytime. It is important to ask the class to reload all loaders and reload each object to use the full loader list:

If a loader will only impact an object, you can also ask the ReflectionNamespace object to load from a new loader:

You can also fill with a simple class map:

Extend the class

Of course, the class is extendable. All methods and properties are protected in order to allow you editing them in a sub class.

Be carefull and be sure to fully understand how it works before investaging in.

Contribution

Report bugs

You have a weird behavior, some classes are not detected, namespaces are missing, exceptions are detected ? Open a ticket with the maximum of information and let us help you :)

Develop

First, fork the project in your organization. When it is done, you need to clone your repository obviously.

After cloning, you need to prepare all the future tests by running the following command: composer prepare-test

Make your modifications and before pushing and opening a PR, run this and be sure that it works great: composer test

Of course, if you add features and code, or simply fix a noticable bug, you need to write tests :)

Thanks by advance for the contributions ;)

Donate

As it took me time and as I still a simple student who needs coffee, do not hesitate to donate here, it would be a pleasure and a recognition of my work :)

PayPal


All versions of reflection-namespace with dependencies

PHP Build Version
Package Version
No informations.
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 nastuzzi-samy/reflection-namespace contains the following files

Loading the files please wait ....