Download the PHP package sympresso/object-press without Composer

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

Sympresso/ObjectPress

ObjectPress is a simple object oriented facade to the global functions and variables provided by WordPress.
All 900+ core WordPress functions are available.

Key Features

Installation

composer require sympresso/object-press

Usage - WordPress Functions

The 900+ core WordPress functions have been grouped into over 50 classes in ObjectPress. Each of these classes are exposed as a public property of the Sympresso\ObjectPress\Wordpress object. For instance the functions has_action, add_action, do_action are all grouped under the property action.

Using ObjectPress, you can call the add_action() the following way...

// Adding a WordPress action...
$wp = new Sympresso\ObjectPress\WordPress();
$wp->action->add_action('save_post',function($postId,$post){
    // Business logic on action save_post goes here
});

Note: ObjectPress is just a simple facade. When you call a method on ObjectPress, it in turn calls the equivalent WordPress function. The key difference is that you don't have to call global functions in your code (which will improve testability.)

Alternative Syntax

The Sympresso\ObjectPress\Wordpress object also implements the __call() magic method. If you prefer, you can skip the property and call the the add_action directly on the WordPress object.

$wp = new Sympresso\ObjectPress\WordPress();
$wp->add_action('save_post',function($postId,$post){
    // Business logic on action save_post goes here
});

Note: The alternative syntax doesn't have the benefit of autocomplete.

Usage - WordPress Global Variables

WordPress has many global variables (https://codex.wordpress.org/Global_Variables). To access these global variables, just access their variable name on the Sympresso\ObjectPress\Wordpress object as if it was an array.

For example, accessing the $post and $wpdb global variables...

$wp = new Sympresso\ObjectPress\WordPress();
$post = $wp['post'];
$wpdb = $wp['wpdb'];

Extending ObjectPress

You can extend ObjectPress by creating an Extension. Extensions in ObjectPress implement the Sympresso\ObjectPress\ExtensionInterface which has three methods that you will need to implement. When you register an extension, all the methods on the class become methods available on the WordPress object and a public property will be dynamically added with the namesspace of your extension.

The methods you will need to implement:

getExtensionNamespace (string) - The unique namespace for your extension.

getGlobalVariables (array) - An array of global variables exposed by your extension.

getExcludedFunctions (array) - An array of methods of your extension class to ignore (Since by default all methods on an extension will be added).

Here is a sample extension that adds the function foo() and global variable $fooGlobal ...

use Sympresso\ObjectPress\AbstractExtension;

class FooExtension extends AbstractExtension
{
    function bar()
    {
        // business logic goes here
    }

    function getExtensionNamespace()
    {
        return 'foo';
    }

    function getGlobalVariables()
    {
        return array('fooGlobal');
    }
}

Next you register your extension...

$wp = new Sympresso\ObjectPress\WordPress();
$wp->addExtension(new FooExtension());

Now you can use the function and global variables...

$wp->foo->bar()                 // namespace syntax
$wp->bar()                      // alternative syntax
$fooGlobal = $wp['fooGlobal']   // accessing global variable

The core WordPress functions and global variables are added using extensions so you can use them for inspiration (located in Sympresso/ObjectPress/CoreExtensions).

Note: You can also override the core extensions by passing an array of extensions to the Sympresso\ObjectPress\WordPress constructor. Be sure to use the same namespace string of the namespace you want to replace.

ObjectPress Namespaces and Functions

Here's a list of all the core WordPress functions supported:


All versions of object-press 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 sympresso/object-press contains the following files

Loading the files please wait ....