How to Create a Compact PHP API in a Single Object - Armory PHP Closure Trait package blog

Recommend this page to a friend!
  All package blogs All package blogs   Armory PHP Closure Trait Armory PHP Closure Trait   Blog Armory PHP Closure Trait package blog   RSS 1.0 feed RSS 2.0 feed   Blog How to Create a Compa...  
  Post a comment Post a comment   See comments See comments (0)   Trackbacks (0)  

Author:

Updated on: 2020-09-04

Posted on: 2020-09-04

Package: Armory PHP Closure Trait

The Armory PHP Closure Trait is a package that provides a trait that you can use in your PHP classes to quickly add a registration and a callback support to register and invoke callback functions to handle class specific events.

Read this short tutorial to learn about several ways to use the PHP Armory Trait.




What is the Armory PHP Closure Trait Useful for?

The Armory PHP Closure Trait provides means to handle events that may happen inside a class by invoking callback functions that we call closures using code that can defined outside that class.

How to Gather Multiple Callback Functions in Single Object? 

This trait is ideal to gather API function calls that usually need multitude of object instances.

Instead of creating an API environment and pass it around, you can gather the important calls in a separate object of a class and pass that object around.

Since the origin object is bound to the closure object using the $this operator, there is no need to get the object again, as the $this operator can be called from the closure function code.

How to Encapsulate Many Global Functions in a Single Object?

Another way of using the Armory PHP Closure Trait is to gather global functions and have them renamed within this trait.

This way code can be developed without knowing the exact spelling of those global function names.

When testing your system it is a simple task to adjust functions, replace them by mockups, or rename or duplicate them.

Conclusion

This article just gives a short overview of the possibilities of Armory PHP Closure Trait package. Lets hope you found it interesting so you can try it and also apprecite its benefits.

This package can be downloaded from download page or be installed using the PHP Composer tool following instructions in the Composer install instructions page.

If you liked this article, please share it with your PHP colleague developers, so they appreciate you more for being nice and they also share nice articles with you too.




You need to be a registered user or login to post a comment

1,562,994 PHP developers registered to the PHP Classes site.
Be One of Us!

Login Immediately with your account on:

FacebookGmail
HotmailStackOverflow
GitHubYahoo


Comments:

No comments were submitted yet.




  Post a comment Post a comment   See comments See comments (0)   Trackbacks (0)  
  All package blogs All package blogs   Armory PHP Closure Trait Armory PHP Closure Trait   Blog Armory PHP Closure Trait package blog   RSS 1.0 feed RSS 2.0 feed   Blog How to Create a Compa...  

For more information send a message to info at phpclasses dot org.