-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5be22b
commit 6d02ebb
Showing
6 changed files
with
147 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
Go headless | ||
=========== | ||
|
||
Since Roadiz v1.6, you can create a 100% *headless* project using: | ||
|
||
.. code-block:: bash | ||
# Create a new Roadiz project | ||
composer create-project roadiz/headless-edition myheadless_project | ||
No more theme, just business logic | ||
---------------------------------- | ||
|
||
**Headless edition get rid of themes** logic in favor of a simple ``src/`` folder | ||
to add custom business logic. All API features are handled by *AbstractApiTheme* which is | ||
registered as a *composer* dependency and in your ``src/AppKernel.php`` file. | ||
|
||
.. code-block:: php | ||
# src/AppKernel.php | ||
public function register(Container $container): void | ||
{ | ||
parent::register($container); | ||
// Headless edition: do not remove API services | ||
$container->register(new \Themes\AbstractApiTheme\Services\AbstractApiServiceProvider()); | ||
$container->register(new \App\AppServiceProvider()); | ||
/* | ||
* Add your own service providers. | ||
*/ | ||
} | ||
Headless structure | ||
------------------ | ||
|
||
* ``bin/``: Contains the Roadiz CLI executable | ||
* ``docker/``: Tools for creating development and production *Docker* image for your project | ||
* ``app/``: Contains every runtime resources from configuration to app cache and nodes-sources entities | ||
|
||
* ``cache/``: Every cache file for *Twig* templates and `Intervention Request <https://github.com/roadiz/roadiz/releases>`_ images (this folder must be writable for PHP) | ||
* ``conf/``: Your setup configuration file(s) (this folder must be writable for PHP) | ||
* ``gen-src/``: Generated PHP code for Doctrine and your Node-types entities (this folder must be writable for PHP) | ||
* ``logs/``: *Monolog* logs folder | ||
|
||
* ``files/``: Private documents and font files root (this folder must be writable for PHP) | ||
* ``samples/``: This folder contains useful configuration and example files for Apache or Nginx webservers | ||
* ``web/``: Your website root, it contains your application entry-points and your public assets | ||
|
||
* ``files/``: Public documents (this folder must be writable for PHP) | ||
* ``themes/``: public assets mirror for each theme, this folder contains symlinks to your ``themes/YourTheme/static`` folder | ||
|
||
* ``src/``: Contains all your website logic | ||
* ``vendor/``: Dependencies folder managed by *Composer* | ||
|
||
Configure CORS | ||
-------------- | ||
|
||
.. code-block:: php | ||
# src/AppServiceProvider.php | ||
/** | ||
* @return array | ||
*/ | ||
$container['api.cors_options'] = [ | ||
'allow_credentials' => true, | ||
// Allow all origin or defines some regex domains | ||
'allow_origin' => ['*'], | ||
'allow_headers' => true, | ||
'origin_regex' => false, | ||
'allow_methods' => ['GET'], | ||
// Expose Link header for NuxtJS to resolve other translations | ||
'expose_headers' => ['Link'], | ||
'max_age' => 60*60*24 | ||
]; | ||
API usage and authentication | ||
---------------------------- | ||
|
||
API endpoints are described in detail in `AbstractApiTheme <https://github.com/roadiz/AbstractApiTheme#generic-roadiz-api>`_ repository README. You'll get automatic: | ||
|
||
* Collection listing for all nodes-sources | ||
* Collection listing per node-type | ||
* Single item endpoint | ||
* User endpoint | ||
* … | ||
|
||
All with query-string parameters for searching and filtering JSON output. | ||
|
||
API can be accessed using: | ||
|
||
* Simple ``X-Api-Key`` access per application for non-user related content | ||
* Or **OAuth2** applications with ``client_credentials`` or ``authorization_code`` grant types. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters