Download the PHP
package mostka/defer without Composer
On this page you can find all versions of the php package
mostka/defer. It is possible to download/install
these versions without Composer. Possible dependencies are resolved
automatically.
Vendor mostka Package defer Short Description A defer function defers the execution of a function until the surrounding function returns. License
Apache-2.0
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.
PHP defer function schedules a function call (the deferred function) to be run immediately before the function
executing the defer returns. It's an unusual but effective way to deal with situations such as resources that must be
released regardless of which path a function takes to return. The canonical examples are unlocking a mutex or closing a
file.
Deferring a call to a function such as Close has two advantages. First, it guarantees that you will never forget to
close the file, a mistake that's easy to make if you later edit the function to add a new return path. Second, it means
that the close sits near the open, which is much clearer than placing it at the end of the function.
Installation
Quick example
will print
3 Rules
The behavior of defer statements is straightforward and predictable. There are three simple rules:
1.A deferred function's arguments are evaluated when the defer statement is evaluated.
In this example, the expression "i" is evaluated when the printf call is deferred.
The deferred call will print 0 after the function returns.
will print
2.Deferred function calls are executed in Last In First Out order after the
surrounding function returns.
This function prints 3210:
3.Deferred functions can`t modify return values when is type, but can modify content of
reference to array or object.
In this example, a deferred function increments increment $o->iafter the surrounding
function returns but not modify returned $i. This example print 2-3:
PHP Limitations
In php defer implementation you can't modify returned value. Can modify only content of returned reference
You need instantiate defer object before use it with or
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 mostka/defer 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.