PHPackages                             nastuzzi-samy/reflection-namespace - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. nastuzzi-samy/reflection-namespace

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nastuzzi-samy/reflection-namespace
==================================

Reflect a namespace, give its classes, its sub-namespaces and more

v1.0.1(6y ago)31.8k21MITPHPCI failing

Since Apr 14Pushed 6y ago1 watchersCompare

[ Source](https://github.com/NastuzziSamy/reflection-namespace)[ Packagist](https://packagist.org/packages/nastuzzi-samy/reflection-namespace)[ RSS](/packages/nastuzzi-samy-reflection-namespace/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (4)Versions (5)Used By (1)

ReflectionNamespace class
=========================

[](#reflectionnamespace-class)

[![Travis Build](https://camo.githubusercontent.com/fa9ed80d19299e9103305b13a1cd8f6bc0f2e0bb0cb354ae266cd0909bbbdaf0/68747470733a2f2f7777772e7472617669732d63692e6f72672f4e617374757a7a6953616d792f7265666c656374696f6e2d6e616d6573706163652e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/fa9ed80d19299e9103305b13a1cd8f6bc0f2e0bb0cb354ae266cd0909bbbdaf0/68747470733a2f2f7777772e7472617669732d63692e6f72672f4e617374757a7a6953616d792f7265666c656374696f6e2d6e616d6573706163652e7376673f6272616e63683d6d6173746572)[![Issues](https://camo.githubusercontent.com/591162a9dad96b792c32b2553a209db35537869f90c7dc5812bd91d5b9b576f5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f4e617374757a7a6953616d792f7265666c656374696f6e2d6e616d6573706163652e737667)](https://camo.githubusercontent.com/591162a9dad96b792c32b2553a209db35537869f90c7dc5812bd91d5b9b576f5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f4e617374757a7a6953616d792f7265666c656374696f6e2d6e616d6573706163652e737667)[![Stars](https://camo.githubusercontent.com/62720ee667de0553340fd1e01afb9332d8d7da3f42c2ec9e50726bf5e7cc7b3b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f4e617374757a7a6953616d792f7265666c656374696f6e2d6e616d6573706163652e737667)](https://camo.githubusercontent.com/62720ee667de0553340fd1e01afb9332d8d7da3f42c2ec9e50726bf5e7cc7b3b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f4e617374757a7a6953616d792f7265666c656374696f6e2d6e616d6573706163652e737667)[![License](https://camo.githubusercontent.com/609917d5b92c7da03f12bdfca9e976c8b18c452c4762acffd85d87bb9e2d0594/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4e617374757a7a6953616d792f7265666c656374696f6e2d6e616d6573706163652e737667)](https://camo.githubusercontent.com/609917d5b92c7da03f12bdfca9e976c8b18c452c4762acffd85d87bb9e2d0594/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4e617374757a7a6953616d792f7265666c656374696f6e2d6e616d6573706163652e737667)

Introduction
------------

[](#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](https://getcomposer.org/doc/04-schema.md#autoload). It loads also from already declared classes, traits and interfaces (also disabled by default).

Installation
------------

[](#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
-----

[](#usage)

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

```
Project example structure:

app/
	Http/
		Controller.php
	Models/
		User.php
vendor/
	...
	random-package/  # RandomPackage defines app/ as \App namespace also
		app/
			Console/
			Models/
				Group.php

```

### Creation

[](#creation)

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

```
