source: src/webapp/apigility/README.md@ 74c3571

debian/bullseye
Last change on this file since 74c3571 was 74c3571, checked in by Joachim Langenbach <joachim.langenbach@…>, 8 years ago

Added gnuboat_mapservice:

it is a REST webservice designed with Apigility to allow the user to upload data, create waters and so on

  • Property mode set to 100644
File size: 7.8 KB
RevLine 
[74c3571]1Apigility Skeleton Application
2==============================
3
4Requirements
5------------
6
7Please see the [composer.json](composer.json) file.
8
9Installation
10------------
11
12### Via release tarball
13
14Grab the latest release via the [Apigility website](http://apigility.org/)
15and/or the [releases page](https://github.com/zfcampus/zf-apigility-skeleton/releases); each release
16has distribution tarballs and zipballs available.
17
18Untar it:
19
20```bash
21$ tar xzf zf-apigility-skeleton-{version}.tgz
22```
23
24(Where `{version}` is the version you downloaded.)
25
26Or unzip, if you chose the zipball:
27
28```bash
29$ unzip zf-apigility-skeleton-{version}.zip
30```
31
32(Where `{version}` is the version you downloaded.)
33
34### Via Composer (create-project)
35
36You can use the `create-project` command from [Composer](http://getcomposer.org/)
37to create the project in one go (you need to install [composer](https://getcomposer.org/doc/00-intro.md#downloading-the-composer-executable)):
38
39```bash
40$ curl -s https://getcomposer.org/installer | php -- --filename=composer
41$ composer create-project -sdev zfcampus/zf-apigility-skeleton path/to/install
42```
43
44### Via Git (clone)
45
46First, clone the repository:
47
48```bash
49# git clone https://github.com/zfcampus/zf-apigility-skeleton.git # optionally, specify the directory in which to clone
50$ cd path/to/install
51```
52
53At this point, you need to use [Composer](https://getcomposer.org/) to install
54dependencies. Assuming you already have Composer:
55
56```bash
57$ composer install
58```
59
60### All methods
61
62Once you have the basic installation, you need to put it in development mode:
63
64```bash
65$ cd path/to/install
66$ composer development-enable
67```
68
69Now, fire it up! Do one of the following:
70
71- Create a vhost in your web server that points the DocumentRoot to the
72 `public/` directory of the project
73- Fire up the built-in web server in PHP(**note**: do not use this for
74 production!)
75
76In the latter case, do the following:
77
78```bash
79$ cd path/to/install
80$ php -S 0.0.0.0:8080 -ddisplay_errors=0 -t public public/index.php
81# OR use the composer alias:
82$ composer serve
83```
84
85You can then visit the site at http://localhost:8080/ - which will bring up a
86welcome page and the ability to visit the dashboard in order to create and
87inspect your APIs.
88
89### NOTE ABOUT USING APACHE
90
91Apache forbids the character sequences `%2F` and `%5C` in URI paths. However, the Apigility Admin
92API uses these characters for a number of service endpoints. As such, if you wish to use the
93Admin UI and/or Admin API with Apache, you will need to configure your Apache vhost/project to
94allow encoded slashes:
95
96```apacheconf
97AllowEncodedSlashes On
98```
99
100This change will need to be made in your server's vhost file (it cannot be added to `.htaccess`).
101
102### NOTE ABOUT OPCACHE
103
104**Disable all opcode caches when running the admin!**
105
106The admin cannot and will not run correctly when an opcode cache, such as APC or
107OpCache, is enabled. Apigility does not use a database to store configuration;
108instead, it uses PHP configuration files. Opcode caches will cache these files
109on first load, leading to inconsistencies as you write to them, and will
110typically lead to a state where the admin API and code become unusable.
111
112The admin is a **development** tool, and intended for use a development
113environment. As such, you should likely disable opcode caching, regardless.
114
115When you are ready to deploy your API to **production**, however, you can
116disable development mode, thus disabling the admin interface, and safely run an
117opcode cache again. Doing so is recommended for production due to the tremendous
118performance benefits opcode caches provide.
119
120### NOTE ABOUT DISPLAY_ERRORS
121
122The `display_errors` `php.ini` setting is useful in development to understand what warnings,
123notices, and error conditions are affecting your application. However, they cause problems for APIs:
124APIs are typically a specific serialization format, and error reporting is usually in either plain
125text, or, with extensions like XDebug, in HTML. This breaks the response payload, making it unusable
126by clients.
127
128For this reason, we recommend disabling `display_errors` when using the Apigility admin interface.
129This can be done using the `-ddisplay_errors=0` flag when using the built-in PHP web server, or you
130can set it in your virtual host or server definition. If you disable it, make sure you have
131reasonable error log settings in place. For the built-in PHP web server, errors will be reported in
132the console itself; otherwise, ensure you have an error log file specified in your configuration.
133
134`display_errors` should *never* be enabled in production, regardless.
135
136### Vagrant
137
138If you prefer to develop with Vagrant, there is a basic vagrant recipe included with this project.
139
140This recipe assumes that you already have Vagrant installed. The virtual machine will try to use localhost:8080 by
141default, so if you already have a server on this port of your host machine, you need to shut down the conflicting
142server first, or if you know how, you can reconfigure the ports in Vagrantfile.
143
144Assuming you have Vagrant installed and assuming you have no port conflicts, you can bring up the Vagrant machine
145with the standard `up` command:
146
147```bash
148$ vagrant up
149```
150
151When the machine comes up, you can ssh to it with the standard ssh forward agent:
152
153```bash
154$ vagrant ssh
155```
156
157The web root is inside the shared directory, which is at `/var/www`; this is
158also the home directory for the vagrant issue, which will be the initial
159directory you land in once you connect via SSH.
160
161The image installs composer during provisioning, meaning you can use it to
162install and update dependencies:
163
164```bash
165# Install dependencies:
166$ vagrant ssh -c 'composer install'
167# Update dependencies:
168$ vagrant ssh -c 'composer update'
169```
170
171You can also manipulate development mode:
172
173```bash
174$ vagrant ssh -c 'composer development-enable'
175$ vagrant ssh -c 'composer development-disable'
176$ vagrant ssh -c 'composer development-status'
177```
178
179> #### Vagrant and VirtualBox
180>
181> The vagrant image is based on `bento/ubuntu-16.04`. If you are using VirtualBox as
182> a provider, you will need:
183>
184> - Vagrant 1.8.5 or later
185> - VirtualBox 5.0.26 or later
186
187For vagrant documentation, please refer to [vagrantup.com](https://www.vagrantup.com/)
188
189### Docker
190
191If you develop or deploy using Docker, we provide configuration for you.
192
193Prepare your development environment using [docker compose](https://docs.docker.com/compose/install/):
194
195```bash
196$ git clone https://github.com/zfcampus/zf-apigility-skeleton
197$ cd zf-apigility-skeleton
198$ docker-compose build
199# Install dependencies via composer, if you haven't already:
200$ docker-compose run apigility composer install
201# Enable development mode:
202$ docker-compose run apigility composer development-enable
203```
204
205Start the container:
206
207```bash
208$ docker-compose up
209```
210
211Access Apigility from `http://localhost:8080/` or `http://<boot2docker ip>:8080/` if on Windows or Mac.
212
213You may also use the provided `Dockerfile` directly if desired.
214
215Once installed, you can use the container to update dependencies:
216
217```bash
218$ docker-compose run apigility composer update
219```
220
221Or to manipulate development mode:
222
223```bash
224$ docker-compose run apigility composer development-enable
225$ docker-compose run apigility composer development-disable
226$ docker-compose run apigility composer development-status
227```
228
229QA Tools
230--------
231
232The skeleton ships with minimal QA tooling by default, including
233zendframework/zend-test. We supply basic tests for the shipped
234`Application\Controller\IndexController`.
235
236We also ship with configuration for [phpcs](https://github.com/squizlabs/php_codesniffer).
237If you wish to add this QA tool, execute the following:
238
239```bash
240$ composer require --dev squizlabs/php_codesniffer
241```
242
243We provide aliases for each of these tools in the Composer configuration:
244
245```bash
246# Run CS checks:
247$ composer cs-check
248# Fix CS errors:
249$ composer cs-fix
250# Run PHPUnit tests:
251$ composer test
252```
Note: See TracBrowser for help on using the repository browser.