Download the PHP package make/accessible without Composer

On this page you can find all versions of the php package make/accessible. 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 accessible

Make/Accessible

Lightweight PHP package that let you test singleton classes and inaccessible (private or protected) instance members.

Table of contents

Installation

composer require make/accessible

Features

Usage

Suppose you have the class bellow:

This class is correct, it does'nt exposes its inner elements (encapsulation) and was designed to do what is supposed to do.

But, how are you going to test this class? Test if the addPersonToGreet() method is really adding $person into $peopleToGreet and greet() method is really distinguishing mens from womens?

You can just make all your class members public, but that way you're breaking encapsulation, thats not good.

So, what can be done here?

Solutions

One way to test addPersonToGreet() would be by directly accessing $peopleToGreet and check if $person is really there:

One way to test greet() would be by directly accessing it:

But of course these methods will fail, its will result in:

Error: Cannot access protected property PeopleGreeter::$peopleToGreet.
Error: Cannot access protected method PeopleGreeter::greet().

because we can't access protected and private members outside of they parent scope.

Another way that works only with protected members is by extending their parent to another class that exposes its methods:

Pros:

Cons:

But of course there's another solution: Using PHP Reflection:

Pros:

Cons:

We're testing only 2 methods, now think about 30 or 50??? No, no... Forget about it!

Using Make/Accessible

Did you saw that??? Just one line of code and we made our tests!!!

We gain access to our PeopleGreeter::class inaccessible members in a common and friendly way! ;)

Pros:

Cons:

As you can see, with Make/Accessible you can now make your projects encapsulated withour fear!

And you can also start testing singleton classes using Make/Accessible. Feature documentation soon.

Best practices

We highly recommend the use of this package for tests purposes only.

Avoid use this package to gain access to encapsulated classes, since it's like break the door of someone's house that does'nt want you to get inside.

If you're testing the same class the same way, we recommend create a function getAccessibleInstance() at the bottom of your test class and there you make the instantiation, mocks, everything you need to instantiate the class you need to test:

For more tips about best practices, please, read our best practices documentation.

Support

Need a new feature? Found a bug? Please open a new issue or send me an email and we'll fix it as soon as possible.

Contribute

Feel free to contribute forking, making changes and pull requests.

Credits

License

The MakeAccessible is licensed under the MIT license. See the license file for more information.


All versions of accessible 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 make/accessible contains the following files

Loading the files please wait ....