Download the PHP package gdbots/pbjx-bundle without Composer

On this page you can find all versions of the php package gdbots/pbjx-bundle. 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 pbjx-bundle

pbjx-bundle-php

Symfony bundle that integrates gdbots/pbjx library.

Configuration

Follow the standard bundle install using gdbots/pbjx-bundle as the composer package name. The default configuration provides in memory processing for all send, publish, request operations. The EventStore and EventSearch are not configured by default.

The examples below assume you're running the DynamoDb EventStore and Elastica EventSearch. These are optional configurations.

config/packages/pbjx.yml:

In your local environment, it is highly recommended to configure the PbjxDebugger.

__config/services_local.yml:__

Pbjx HTTP Endpoints

Pbjx is ready to be used within your app and console commands but it's not yet available via HTTP. Providing the HTTP features is very powerful but can be very dangerous if you don't secure it correctly.

All of the usual rules apply when securing your app. Authentication and authorization is up to you, however, Symfony makes this fairly easy using the security components.

Example security configuration:

To enable Pbjx http endpoints you must include the routes. In config/routes.yml:

Once this is in place ANY pbjx messages can be sent to the endpoint /pbjx/vendor/package/category/message. This url is the configured prefix and then the SchemaCurie resolved to a url.

Why not just use /pbjx? It is a huge benefit to have the full path to the SchemaCurie for logging, authorization, load balancing, debugging, etc.

Example curl request:

Example ajax request:

If your SchemaCurie contains an empty category segment, use "_" in its place in the url.

Controllers

The recommended way to use Pbjx in a controller is to use Symfony dependency injection for the pbjx services you need and if necessary import the PbjxControllerTrait to get helper methods for rendering pbj into twig templates.

PbjxControllerTrait::renderPbj

This is a convenience method that accepts a pbj message and derives the template name using pbjTemplate and calls Symfony's render method (from framework bundle Controller).

The template will have pbj as a variable which is the message object itself.

TIP: {{ pbj }} will dump the message to yaml for easy debugging in twig, or {{ pbj|json_encode(constant('JSON_PRETTY_PRINT')) }}

PbjxControllerTrait::pbjTemplate

Returns a reference to a twig template based on the schema of the provided message (pbj schema). This allows for component style development for pbj messages. You are asking for a template that can render your message (e.g. Article) as a "card", "modal", "page", etc.

This can be combined with gdbots/app-bundle DeviceViewRendererTrait::renderUsingDeviceView (the renderPbj method does this automatically).

What you end up with is a namespaced path reference to a template which conforms to the Symfony template naming best practices. Examples:

SchemaCurie Template Format Twig Paths
acme:blog:node:article page html @acme_blog/node/article/page.html.twig
acme:users:request:search-users-response page json @acme_users/request/search_users_response/page.json.twig
acme:users:node:user card html @acme_users/node/user/card.html.twig

Twig Extension

A few twig functions are provided to expose most of what controllers can do to your twig templates.

Twig Function: pbj_template

Returns a reference to a twig template based on the schema of the provided message (pbj schema). This allows for component style development for pbj messages. You are asking for a template that can render your message (e.g. Article) as a "card", "modal", "slackpost", etc. and optionally that template can be device view specific (card.smartphone.html.twig)_.

Example:

Twig Function: pbj_url

Returns a named URL to a pbj instance. This depends on gdbots/uri-template package which provides a way to register uri templates. These are expected to be in the format vendor:label.template_name, e.g. acme:article.canonical.

Example:

Twig Function: uri_template_expand

When you need to expand a URI template by id direct with your own variables, use this function.

Example:

Twig Function: pbjx_request

In the same way that you can embed a Symfony controller within twig you can embed a pbjx request in twig. This function performs a $pbjx->request($request); and returns the response. If debugging is enabled an exception will be thrown (generally in dev), otherwise it will be logged and null will be returned.

Example:

Console Commands

This library provides quite a few commands to make managing the services of Pbjx simple. Run the Symfony console and look for pbjx commands.

The most useful is probably going to be the pbjx and pbjx:batch commands. These run pbjx just like you do in your application code and return the resulting pbj.

Pbjx is designed to run the the same way via cli, application code and http.

Example response:

Review the --help on the pbjx commands for more details.

Library Development

Pbj has a concept of mixins which is just a schema that can be added to other schemas. This strategy is useful for creating consistent data structures and allowing for library development to be done against mixins and not concrete schemas.

A mixin cannot be used by itself to create messages, it must be added to a schema that is NOT a mixin.

This bundle provides a compiler pass that automatically registers handlers for pbjx command and requests.

Example:

Fictional WidgetCo makes widgets for websites by creating mixins and libraries to provide implementations for those mixins.

Your company Acme now has a blog and wants to use WidgetCo mixins AND the implementation provided by WidgetCoBlogBundle.

You can still override if you want to extend or replace what widgetco provides by implementing your own handler using the PbjxHandler interface.

You can provide concrete schemas and implementations in libraries. There are pros and cons to both strategies, the biggest issue is that the schema is not as easily customized at the application level if the library is not developed using mixins.

Pbjx itself is a library built on mixins for Command, Request and Event messages.


All versions of pbjx-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
gdbots/pbjx Version ^4.2
gdbots/uri-template Version ^2.0
symfony/console Version ^6.4 || ^7.0
symfony/framework-bundle Version ^6.4 || ^7.0
twig/twig Version ^3.8
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 gdbots/pbjx-bundle contains the following files

Loading the files please wait ....