PHP Shortcut Classes: Create shorter name functions to create objects

Recommend this page to a friend!
  Info   Documentation   View files (8)   Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 94 All time: 9,445 This week: 327
Version License PHP version Categories
shortcut 1.0MIT/X Consortium ...5PHP 5, Language, Code Generation
Description Author

This package can create shorter name functions to create objects.

It can generate PHP code that is equivalent to create objects of given classes with eventual construction parameters, so it takes typing less code to create those class parameters.

The generate code for shortcuts is stored in a given directory so it can be cached and executed faster next time it is called.

Innovation Award
PHP Programming Innovation award nominee
April 2019
Number 4
In PHP there are many functions useful functions that have long names. Therefore they take more time to type especially when you use them many times.

This package can help reducing the time it is necessary to enter the names of those functions in the PHP scripts that they are used by creating shortcuts that are assigned to class functions with shorter names.

Manuel Lemos
Picture of zinsou A.A.E.Mo´se
  Performance   Level  
Name: zinsou A.A.E.Mo´se is available for providing paid consulting. Contact zinsou A.A.E.Mo´se .
Classes: 50 packages by
Country: Benin Benin
Age: 30
All time rank: 7971 in Benin Benin
Week rank: 48 1 in Benin Benin
Innovation award
Innovation award
Nominee: 23x

Winner: 2x


Class Instantiation Shortcut for PHP

Build Status Scrutinizer Code Quality Build Status Code Intelligence Status

Library which create custom Shortcut for classes Instantiation.

Requires: PHP 5.3+

Why Create Shortcut for PHP classes Instantiation?

Typically you would create Shortcut for class instantiation if:

  1. You need something more customized just like PHP create arrays with the array() function .
  2. You want to be more productive avoiding the "new" keyword usage but also too long class name repetitive usage .
  3. Instead of a gain of productivity You just are nostalgic of the times when you were using Python or the old fashion style of javaScript when you were not load yourself of the "new" keyword to instantiate a new object.
  4. Just for the fun to do it.
  5. Because you are just crazy in love with functions -:).

How to use it

Require the library by issuing this command:

composer require manuwhat/Shortcut

Add require 'vendor/autoload.php'; to the top of your script.

Next, create a Shortcut, just like this:

use ezama/Shortcut;


The Shortcut is once and forever until cache suppression automatically created and the code included then you can use it in your script:

$obj=chosen_Shortcut_name(); // ==> ### if no chosen name has been specified then you may use!
$obj=fullQualifiedclassname();// of course you must pass the arguments if the constructor require them at instantiation

By default shortcuts are cached in a default directory but you can specify a custom directory path where shortcuts will be saved using

use ezama/Shortcut;

Keep in mind that only one custom Shortcut can be defined per class and that only instantiable classes can be used.

To run unit tests

phpunit  ./tests
File Role Description
src (2 files)
tests (1 file)
.travis.yml Data Auxiliary data
composer.json Data Auxiliary data
LICENSE Lic. License text
phpunit.xml Data Auxiliary data Doc. Documentation

  Files  /  src  
File Role Description
   Shortcut.php Class Class source
   shortcutQueryBuilder.php Class Class source

  Files  /  tests  
File Role Description
   ShortcutTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:9,445
This week:327

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