Download the PHP package yanc3k/api-content-provider-bundle without Composer

On this page you can find all versions of the php package yanc3k/api-content-provider-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 api-content-provider-bundle

README

This Bundles purpose is to enable the Open Source CMS Sulu to serve as a headless back-end. Content pages can be created in the Sulu admin area. All returned content data is stored in simple key-value-pairs. The keys can be set freely and the content is created like in usual Sulu applications.

Use it for ReactJs or Angular WebApps or React Native, native, Expo JS or other mobile apps.

Available Sulu Content Types

Sulu offers many different content types. A content type may be something like a text line input, a full text editor or a media selection for images and other files. Since they may differ a lot in the way they need to be handled for headless usage, they all need to be handled differently. By now I managed to implement the ones I identified as most important, at least for my situation.

The following Sulu content types are available at the moment

Text line

Shows a simple text line, the inserted content will be saved as simple string. (From the Sulu CMS docs)

Text editor

Shows a rich text editor, capable of formatting text as well. The output of the editor will be stored as HTML in a string field. (From the Sulu CMS docs)

Media selection

Shows a list with the possibility to assign some assets from the media section to a page. Also allows to define a position, which can be handled later in the template. (From the Sulu CMS docs)

Installation

Install the bundle using composer:

Enable the Bundle in the app/AdminKernel.php AND app/WebsiteKernel.php file: notice: This is done a little bit differently as in vanilla Symfony applications.

Usage

This bundle provides you with an easy way to create page content using the Sulu CMS as a headless back end. In Sulu you can easily create new templates for the CMS admin area. Those templates are written in XML. The ApiContentProviderBundle features a controller that can handle the data as it comes from Sulu on a page request.

To use it you need to do two things, explained in detail below. Important: This is in no way interfering with other functionalities of Sulu. You won't lose anything by installing this bundle alongside a common setup.

Easiest way

The ApiContentProviderBundle comes with a Sulu XML template ready to go. You need to copy it to your app/Resources/templates/pages folder. You can do that manually or by using this when in the project root:

From now on you can choose the api-content template in any content page in the Sulu CMS admim area.

The Content page

The content page, defined by the XML template you just copied, features the following:

IMPORTANT Every key-value-pair must be one block! In each block you have the possibily to define a key that will be the key the content of this block will be stored under in the JSON response. Then you can set a value, or content, for this key. Only use one of the inputs (text line, text editor, media selection, ...).

The screenshot shows the content page in Sulu using the api-content template. There are three key-values defined.

The response for a request to http://canvas.lo/api-content-canvas in the browser will return the following JSON. Note: The URL obove is based on my local setup and will differ based on the URL you defined in your virual host settings for your webserver. The /api-content-canvas part is defined in the content page and free of choice.

Lets give that a litte more detail:

The url in the response is the url you requested in the browser without locale and base URL.

The title in the response is the content page title defined in Sulu.

The headline-1 in the response is the first dynamic key in the JSON response. It is the one that was defined in the first key-value block in Sulu. The name of this key is entirely up to you.

The image-user key in the response is a media selection in Sulu. There you can chose a file from the easily manageable media library of Sulu. The relative path to that file will be returned. This path is versioned.

The article-1 key in the JSON response holds the content of a rich text editor input provided by Sulu. As you can see, it is HTML, that can be used in the front end, formatted as it is.


All versions of api-content-provider-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
symfony/dependency-injection Version ~2.3|~3.0
symfony/expression-language Version ~2.3|~3.0
symfony/event-dispatcher Version ~2.3|~3.0
symfony/http-kernel Version ~2.3|~3.0
psr/log Version ~1.0
sulu/sulu Version ~1.6.0
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 yanc3k/api-content-provider-bundle contains the following files

Loading the files please wait ....