Download the PHP
package studiow/autowire without Composer
On this page you can find all versions of the php package
studiow/autowire. It is possible to download/install
these versions without Composer. Possible dependencies are resolved
automatically.
Vendor studiow Package autowire Short Description Autowire-able container License
MIT
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.
This package provides a sort of autowiring wrapper for any psr/container-compatible container.
Installation
The (highly) recommended way to install studiow/autowire is by using Composer
How to use
In my application, I have a Configuration object. There is also an interface for objects that can use this Configuration.
I like to use league/container as a DI container, so let's do just that:
Now I would like to make sure that our Configuration object gets passed around to any object that needs it. One way to do this is by defining all classes in the container:
This works great! Unfortunately, we'll need to this for any class that needs the Configuration object. Boring!
Let's see what we can do if we wrap our Container in an autowire container:
This looks familiar: it's the same DI container as before, but it now gets wrapped into an autowire container.
Here's what we want the autowire container to do: if an object implements the HasConfiguration interface, use the setConfiguration method to pass on the Configuration object
The attach method takes 2 arguments: the name of the interface, and a callback. The callback also has 2 arguments: the object we're dealing with, and the autowire container.
The callback will now automatically be executed when resolving objects from the container
If you want, you can bypass "add classes to container" too:
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 studiow/autowire contains the following files
Loading the files please wait ....
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.