Download the PHP package lexprodsas/contao-content-api-bundle without Composer

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

Contao Content API

We at Die Schittigs love Contao, but the web moves forward and static HTML templating just doesn't cut it anymore. Thus we came up with an easily digestible JSON-API to access Contao content via JavaScript (or anything else that can handle JSON).

With the Contao Content API it is possible to write the entire Frontend of your website in React.js, Angular, vue, or any other JS-framework. All while still using the great Contao Backend.

Requirements

You'll need an up-and-running Contao 4.4.x installation. Please note that the API is not compatible with Contao 3.x.

Installation

Install composer if you haven't already, enter this command in the main directory of your Contao installation:

composer require dieschittigs/contao-content-api

Contao Content API is now installed and ready to use.

Usage

Once installed, the following routes are available:

/api/sitemap

Gets the sitemap including the root pages.

Example

/api/sitemap/flat

Gets all pages as key value pairings where the key is the URL.

Example

/api/urls[?file=sitemap]

Gets all URLs from the generated sitemap XML(s). If you define a file, only that XML will be parsed.

Example

/api/page?url=/about/team.html

Gets the page, including all articles and contents at the url.

Example

/api/newsreader?url=/news/detail/new-website.html

Gets the news reader content from the url

Example

/api/?url=/page/or/newsarticle.html

Tries to get the page at the url, and contents from any reader

Example

/api/user

Gets the logged-in frontend user, if available.

Example

/api/module?id=5

Gets the content of a module by id

Example

/api/text?file=tl_news,modules

Gets the content of a language file by filename(s)

Example

/api/file?path=files/uploads&depth=2

Gets the file or directory at path and also it's children, limited by depth

Example

All routes also take the additional lang parameter (e.g. ?lang=de). If you need to override the language.

Configuration

Disabling the API

Edit your parameters.yml.

parameters:
…
content_api_enabled:
    false
…

The API routes are now all disabled. This may be helpful if you only want to use the classes included in the bundle.

Response headers

Edit your parameters.yml.

parameters:
…
content_api_headers:
    'Access-Control-Allow-Origin': 'https://mysite.org'
…

These headers will be added to all responses from the API.

Custom readers

Contao has the concept of Reader Module (e.g. News Reader). These can be inserted anywhere inside of an article where they read the URL to display their contents. If you want to add additional Reader Modules, you can do so by adding them in your parameters.yml.

parameters:
…
    content_api_readers:
        newsreader: NewsModel
        blogreader: BlogModel
…

Please note that the second parameter is the model class, not the module class. The new reader is now available at

/api/blogreader?url=/blog/detail/on-the-topic.html

or, if you want to include the whole page, at

/api?url=/blog/detail/on-the-topic.html

Internally the API tries to instantiate the model with the alias found in the url. It also tries to add all ContentModels it can find.

Hooks

We provide some basic hooks:

Documentation

The classes crafted for the API might be a good starting point if you want to build anything on top of Contao.

Check out the docs here

Contribution

Bug reports and pull requests are very welcome :)


© Die Schittigs GmbH 2019


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

PHP Build Version
Package Version
Requires php Version ^5.6|^7.0
contao/core-bundle Version ^4.4
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 lexprodsas/contao-content-api-bundle contains the following files

Loading the files please wait ....