Skip to content
Snippets Groups Projects
Commit 1de5c6de authored by bertrandgauthier's avatar bertrandgauthier
Browse files

Commit initial

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 757 additions and 0 deletions
nbproject
._*
.~lock.*
.buildpath
.DS_Store
.idea
.project
.settings
vendor/
public/vendor/
config/development.config.php
config/autoload/local.php
config/autoload/*.local.php
!public/vendor/README.md
data/cache/*
!data/cache/.gitkeep
# Composer files
vendor/
# Local configs
config/development.config.php
config/autoload/*.local.php
# Binary gettext files
*.mo
# Data
data/logs/
data/cache/
data/sessions/
data/tmp/
temp/
!data/cache/.gitkeep
#Doctrine 2
data/DoctrineORMModule/Proxy/
data/DoctrineORMModule/cache/
phpunit.xml
# Metadata PhpStorm
.idea/
# Contributor Code of Conduct
The Zend Framework project adheres to [The Code Manifesto](http://codemanifesto.com)
as its guidelines for contributor interactions.
## The Code Manifesto
We want to work in an ecosystem that empowers developers to reach their
potential — one that encourages growth and effective collaboration. A space that
is safe for all.
A space such as this benefits everyone that participates in it. It encourages
new developers to enter our field. It is through discussion and collaboration
that we grow, and through growth that we improve.
In the effort to create such a place, we hold to these values:
1. **Discrimination limits us.** This includes discrimination on the basis of
race, gender, sexual orientation, gender identity, age, nationality, technology
and any other arbitrary exclusion of a group of people.
2. **Boundaries honor us.** Your comfort levels are not everyone’s comfort
levels. Remember that, and if brought to your attention, heed it.
3. **We are our biggest assets.** None of us were born masters of our trade.
Each of us has been helped along the way. Return that favor, when and where
you can.
4. **We are resources for the future.** As an extension of #3, share what you
know. Make yourself a resource to help those that come after you.
5. **Respect defines us.** Treat others as you wish to be treated. Make your
discussions, criticisms and debates from a position of respectfulness. Ask
yourself, is it true? Is it necessary? Is it constructive? Anything less is
unacceptable.
6. **Reactions require grace.** Angry responses are valid, but abusive language
and vindictive actions are toxic. When something happens that offends you,
handle it assertively, but be respectful. Escalate reasonably, and try to
allow the offender an opportunity to explain themselves, and possibly correct
the issue.
7. **Opinions are just that: opinions.** Each and every one of us, due to our
background and upbringing, have varying opinions. The fact of the matter, is
that is perfectly acceptable. Remember this: if you respect your own
opinions, you should respect the opinions of others.
8. **To err is human.** You might not intend it, but mistakes do happen and
contribute to build experience. Tolerate honest mistakes, and don't hesitate
to apologize if you make one yourself.
# CONTRIBUTING
Apigility and related modules (of which this is one) are open source and licensed
as [BSD-3-Clause](http://opensource.org/licenses/BSD-3-Clause). Contributions
are welcome in the form of issue reports and pull requests.
All pull requests should include unit tests when applicable, and should follow
our coding standards (more on these below); failure to do so may result in
rejection of the pull request. If you need help writing tests, please ask on the
developer mailing list and/or in IRC.
## RESOURCES
If you wish to contribute to Apigility modules, please be sure to
read/subscribe to the following resources:
- [Coding Standards](https://github.com/zendframework/zf2/wiki/Coding-Standards)
- [ZF Git Guide](https://github.com/zendframework/zf2/blob/master/README-GIT.md)
- [Apigility developer mailing list](http://bit.ly/apigility-dev)
- Apigility developer IRC channel: #apigility-dev on Freenode.net
If you are working on new features, refactoring an existing module, or proposing
a new module, please send an email to the developer mailing list.
## REPORTING POTENTIAL SECURITY ISSUES
If you have encountered a potential security vulnerability in any Apigility
module, please report it to us at [zf-security@zend.com](mailto:zf-security@zend.com).
We will work with you to verify the vulnerability and patch it.
When reporting issues, please provide the following information:
- Module(s) affected
- A description indicating how to reproduce the issue
- A summary of the security vulnerability and impact
We request that you contact us via the email address above and give the project
contributors a chance to resolve the vulnerability and issue a new release prior
to any public exposure; this helps protect Apigility users, and provides them
with a chance to upgrade and/or update in order to protect their applications.
For sensitive email communications, please use
[our PGP key](http://framework.zend.com/zf-security-pgp-key.asc).
## RUNNING TESTS
First, use [Composer](https://getcomposer.org) to install all dependencies:
```bash
$ composer install
```
Make sure that `zendframework/zend-test` is installed:
```bash
$ composer require --dev zendframework/zend-test
```
To run tests:
```bash
$ composer test
```
## CODING STANDARDS
While Apigility uses Zend Framework coding standards, in practice, we verify
against [PSR-2](http://www.php-fig.org/psr/psr-2/).
First, ensure you've installed dependencies via composer:
```bash
$ composer require --dev squizlabs/php_codesniffer
```
To check for CS issues:
```bash
$ composer cs-check
```
This will report CS issues. Alternately, you can have most errors automatically
fixed as well:
```bash
$ composer cs-fix
```
After running `composer cs-fix`, be sure to add and commit any files that were
updated, after first verifying that the changes do not break tests.
## Conduct
Please see our [CONDUCT.md](CONDUCT.md) to understand expected behavior when interacting with others in the project.
#
# Use this dockerfile to run apigility.
#
# Start the server using docker-compose:
#
# docker-compose build
# docker-compose up
#
# You can install dependencies via the container:
#
# docker-compose run apigility composer install
#
# You can manipulate dev mode from the container:
#
# docker-compose run apigility composer development-enable
# docker-compose run apigility composer development-disable
# docker-compose run apigility composer development-status
#
# OR use plain old docker
#
# docker build -f Dockerfile-dev -t apigility .
# docker run -it -p "8080:80" -v $PWD:/var/www apigility
#
FROM php:7.0-apache
ENV http_proxy=http://10.14.128.99:3128
ENV https_proxy=http://10.14.128.99:3128
ENV no_proxy=localhost,127.0.0.1,.unicaen.fr
RUN apt-get update \
&& apt-get install -y git zlib1g-dev \
&& docker-php-ext-install zip \
&& a2enmod rewrite \
&& sed -i 's!/var/www/html!/var/www/public!g' /etc/apache2/sites-available/000-default.conf \
&& mv /var/www/html /var/www/public \
&& curl -sS https://getcomposer.org/installer \
| php -- --install-dir=/usr/local/bin --filename=composer \
&& echo "AllowEncodedSlashes On" >> /etc/apache2/apache2.conf
WORKDIR /var/www
Copyright (c) 2013 - 2016, Zend Technologies USA, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- Neither the name of Zend Technologies USA, Inc. nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
README.md 0 → 100644
Apigility Skeleton Application
==============================
Requirements
------------
Please see the [composer.json](composer.json) file.
Installation
------------
### Via release tarball
Grab the latest release via the [Apigility website](http://apigility.org/)
and/or the [releases page](https://github.com/zfcampus/zf-apigility-skeleton/releases); each release
has distribution tarballs and zipballs available.
Untar it:
```bash
$ tar xzf zf-apigility-skeleton-{version}.tgz
```
(Where `{version}` is the version you downloaded.)
Or unzip, if you chose the zipball:
```bash
$ unzip zf-apigility-skeleton-{version}.zip
```
(Where `{version}` is the version you downloaded.)
### Via Composer (create-project)
You can use the `create-project` command from [Composer](http://getcomposer.org/)
to create the project in one go (you need to install [composer](https://getcomposer.org/doc/00-intro.md#downloading-the-composer-executable)):
```bash
$ curl -s https://getcomposer.org/installer | php -- --filename=composer
$ composer create-project -sdev zfcampus/zf-apigility-skeleton path/to/install
```
### Via Git (clone)
First, clone the repository:
```bash
# git clone https://github.com/zfcampus/zf-apigility-skeleton.git # optionally, specify the directory in which to clone
$ cd path/to/install
```
At this point, you need to use [Composer](https://getcomposer.org/) to install
dependencies. Assuming you already have Composer:
```bash
$ composer install
```
### All methods
Once you have the basic installation, you need to put it in development mode:
```bash
$ cd path/to/install
$ composer development-enable
```
Now, fire it up! Do one of the following:
- Create a vhost in your web server that points the DocumentRoot to the
`public/` directory of the project
- Fire up the built-in web server in PHP(**note**: do not use this for
production!)
In the latter case, do the following:
```bash
$ cd path/to/install
$ php -S 0.0.0.0:8080 -ddisplay_errors=0 -t public public/index.php
# OR use the composer alias:
$ composer serve
```
You can then visit the site at http://localhost:8080/ - which will bring up a
welcome page and the ability to visit the dashboard in order to create and
inspect your APIs.
### NOTE ABOUT USING APACHE
Apache forbids the character sequences `%2F` and `%5C` in URI paths. However, the Apigility Admin
API uses these characters for a number of service endpoints. As such, if you wish to use the
Admin UI and/or Admin API with Apache, you will need to configure your Apache vhost/project to
allow encoded slashes:
```apacheconf
AllowEncodedSlashes On
```
This change will need to be made in your server's vhost file (it cannot be added to `.htaccess`).
### NOTE ABOUT OPCACHE
**Disable all opcode caches when running the admin!**
The admin cannot and will not run correctly when an opcode cache, such as APC or
OpCache, is enabled. Apigility does not use a database to store configuration;
instead, it uses PHP configuration files. Opcode caches will cache these files
on first load, leading to inconsistencies as you write to them, and will
typically lead to a state where the admin API and code become unusable.
The admin is a **development** tool, and intended for use a development
environment. As such, you should likely disable opcode caching, regardless.
When you are ready to deploy your API to **production**, however, you can
disable development mode, thus disabling the admin interface, and safely run an
opcode cache again. Doing so is recommended for production due to the tremendous
performance benefits opcode caches provide.
### NOTE ABOUT DISPLAY_ERRORS
The `display_errors` `php.ini` setting is useful in development to understand what warnings,
notices, and error conditions are affecting your application. However, they cause problems for APIs:
APIs are typically a specific serialization format, and error reporting is usually in either plain
text, or, with extensions like XDebug, in HTML. This breaks the response payload, making it unusable
by clients.
For this reason, we recommend disabling `display_errors` when using the Apigility admin interface.
This can be done using the `-ddisplay_errors=0` flag when using the built-in PHP web server, or you
can set it in your virtual host or server definition. If you disable it, make sure you have
reasonable error log settings in place. For the built-in PHP web server, errors will be reported in
the console itself; otherwise, ensure you have an error log file specified in your configuration.
`display_errors` should *never* be enabled in production, regardless.
### Vagrant
If you prefer to develop with Vagrant, there is a basic vagrant recipe included with this project.
This recipe assumes that you already have Vagrant installed. The virtual machine will try to use localhost:8080 by
default, so if you already have a server on this port of your host machine, you need to shut down the conflicting
server first, or if you know how, you can reconfigure the ports in Vagrantfile.
Assuming you have Vagrant installed and assuming you have no port conflicts, you can bring up the Vagrant machine
with the standard `up` command:
```bash
$ vagrant up
```
When the machine comes up, you can ssh to it with the standard ssh forward agent:
```bash
$ vagrant ssh
```
The web root is inside the shared directory, which is at `/var/www`; this is
also the home directory for the vagrant issue, which will be the initial
directory you land in once you connect via SSH.
The image installs composer during provisioning, meaning you can use it to
install and update dependencies:
```bash
# Install dependencies:
$ vagrant ssh -c 'composer install'
# Update dependencies:
$ vagrant ssh -c 'composer update'
```
You can also manipulate development mode:
```bash
$ vagrant ssh -c 'composer development-enable'
$ vagrant ssh -c 'composer development-disable'
$ vagrant ssh -c 'composer development-status'
```
> #### Vagrant and VirtualBox
>
> The vagrant image is based on `bento/ubuntu-16.04`. If you are using VirtualBox as
> a provider, you will need:
>
> - Vagrant 1.8.5 or later
> - VirtualBox 5.0.26 or later
For vagrant documentation, please refer to [vagrantup.com](https://www.vagrantup.com/)
### Docker
If you develop or deploy using Docker, we provide configuration for you.
Prepare your development environment using [docker compose](https://docs.docker.com/compose/install/):
```bash
$ git clone https://github.com/zfcampus/zf-apigility-skeleton
$ cd zf-apigility-skeleton
$ docker-compose build
# Install dependencies via composer, if you haven't already:
$ docker-compose run apigility composer install
# Enable development mode:
$ docker-compose run apigility composer development-enable
```
Start the container:
```bash
$ docker-compose up
```
Access Apigility from `http://localhost:8080/` or `http://<boot2docker ip>:8080/` if on Windows or Mac.
You may also use the provided `Dockerfile` directly if desired.
Once installed, you can use the container to update dependencies:
```bash
$ docker-compose run apigility composer update
```
Or to manipulate development mode:
```bash
$ docker-compose run apigility composer development-enable
$ docker-compose run apigility composer development-disable
$ docker-compose run apigility composer development-status
```
QA Tools
--------
The skeleton does not come with any QA tooling by default, but does ship with
configuration for each of:
- [phpcs](https://github.com/squizlabs/php_codesniffer)
- [phpunit](https://phpunit.de)
Additionally, it comes with some basic tests for the shipped
`Application\Controller\IndexController`.
If you want to add these QA tools, execute the following:
```bash
$ composer require --dev phpunit/phpunit squizlabs/php_codesniffer zendframework/zend-test
```
We provide aliases for each of these tools in the Composer configuration:
```bash
# Run CS checks:
$ composer cs-check
# Fix CS errors:
$ composer cs-fix
# Run PHPUnit tests:
$ composer test
```
{
"name": "zfcampus/zf-apigility-skeleton",
"description": "Skeleton Application for Apigility",
"type": "library",
"license": "BSD-3-Clause",
"keywords": [
"api",
"apigility",
"framework",
"zf2"
],
"homepage": "http://apigility.org/",
"support": {
"email": "apigility-users@zend.com",
"irc": "irc://irc.freenode.net/apigility",
"source": "https://github.com/zfcampus/zf-apigility-skeleton",
"issues": "https://github.com/zfcampus/zf-apigility-skeleton/issues"
},
"config": {
"process-timeout": 5000
},
"extra": {
"branch-alias": {
"dev-master": "1.4-dev",
"dev-develop": "1.5-dev"
}
},
"require": {
"php": "^5.6 || ^7.0",
"zendframework/zend-component-installer": "^1.0 || ^0.5 || ^1.0.0-dev@dev",
"zfcampus/zf-apigility": "^1.3",
"zfcampus/zf-apigility-documentation": "^1.2.3",
"zfcampus/zf-development-mode": "^3.0",
"zfcampus/zf-apigility-doctrine": "^2.1"
},
"require-dev": {
"zendframework/zend-developer-tools": "^1.1",
"zfcampus/zf-apigility-admin": "^1.5.9",
"zfcampus/zf-asset-manager": "^1.1.1",
"zfcampus/zf-composer-autoloading": "^1.0",
"zfcampus/zf-deploy": "^1.2"
},
"suggest": {
"zfcampus/zf-apigility-doctrine": "zfcampus/zf-apigility-doctrine ^2.1 to create Doctrine-Connected REST services",
"zfcampus/zf-http-cache": "zfcampus/zf-http-cache ^1.3 to add HTTP caching to your API",
"zfr/zfr-cors": "zfr/zfr-cors ^1.2 to add CORS support to your API"
},
"autoload": {
"psr-4": {
"Application\\": "module/Application/src/"
}
},
"autoload-dev": {
"psr-4": {
"ApplicationTest\\": "module/Application/test/"
},
"files": [
"src/Apigility/constants.php"
]
},
"scripts": {
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"development-disable": "zf-development-mode disable",
"development-enable": "zf-development-mode enable",
"development-status": "zf-development-mode status",
"serve": "php -S 0.0.0.0:8080 -t public/ public/index.php",
"test": "phpunit"
}
}
This diff is collapsed.
<?php
/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2014-2016 Zend Technologies USA Inc. (http://www.zend.com)
*/
return [
// Retrieve the list of modules for this application.
'modules' => include __DIR__ . '/modules.config.php',
// This should be an array of paths in which modules reside.
// If a string key is provided, the listener will consider that a module
// namespace, the value of that key the specific path to that module's
// Module class.
'module_listener_options' => [
'module_paths' => [
'./module',
'./vendor'
],
// Using __DIR__ to ensure cross-platform compatibility. Some platforms --
// e.g., IBM i -- have problems with globs that are not qualified.
'config_glob_paths' => [realpath(__DIR__) . '/autoload/{,*.}{global,local}.php'],
'config_cache_key' => 'application.config.cache',
'config_cache_enabled' => true,
'module_map_cache_key' => 'application.module.cache',
'module_map_cache_enabled' => true,
'cache_dir' => 'data/cache/',
],
];
local.php
*.local.php
About this directory:
=====================
By default, this application is configured to load all configs in
`./config/autoload/{,*.}{global,local}.php`. Doing this provides a
location for a developer to drop in configuration override files provided by
modules, as well as cleanly provide individual, application-wide config files
for things like database connections, etc.
<?php
/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2014-2016 Zend Technologies USA Inc. (http://www.zend.com)
*/
use ZF\Apigility\Admin\Model\ModulePathSpec;
return [
'view_manager' => [
'display_exceptions' => true,
],
'zf-apigility-admin' => [
'path_spec' => ModulePathSpec::PSR_4,
],
'zf-configuration' => [
'enable_short_array' => true,
'class_name_scalars' => true,
],
];
<?php
/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c] 2014-2016 Zend Technologies USA Inc. (http://www.zend.com]
*/
return [
'zf-content-negotiation' => [
'selectors' => [],
],
'db' => [
'adapters' => [
'dummy' => [],
],
],
];
<?php
/**
* Local Configuration Override
*
* This configuration override file is for overriding environment-specific and
* security-sensitive configuration information. Copy this file without the
* .dist extension at the end and populate values as needed.
*
* @NOTE: This file is ignored from Git by default with the .gitignore included
* in ZendSkeletonApplication. This is a good practice, as it prevents sensitive
* credentials from accidentally being committed into version control.
*/
return [];
<?php
/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2014 Zend Technologies USA Inc. (http://www.zend.com)
*/
/**
* Global Configuration Override
*
* You can use this file for overriding configuration values from modules, etc.
* You would place values in here that are agnostic to the environment and not
* sensitive to security.
*
* @NOTE: In practice, this file will typically be INCLUDED in your source
* control, so do not include passwords or other sensitive information in this
* file.
*/
return [
// ...
];
<?php
/**
* This file was autogenerated by zfcampus/zf-mvc-auth (bin/zf-mvc-auth-oauth2-override.php),
* and overrides the ZF\OAuth2\Service\OAuth2Server to provide the ability to create named
* OAuth2\Server instances.
*/
return [
'service_manager' => [
'factories' => [
\ZF\OAuth2\Service\OAuth2Server::class => \ZF\MvcAuth\Factory\NamedOAuth2ServerFactory::class,
],
],
];
<?php
/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2014 Zend Technologies USA Inc. (http://www.zend.com)
*/
return [
'view_manager' => [
'strategies' => [
'ViewJsonStrategy',
],
],
];
<?php
/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2014-2016 Zend Technologies USA Inc. (http://www.zend.com)
*/
return [
// Development time modules
'modules' => [
'ZendDeveloperTools',
'ZF\Apigility\Admin',
],
// development time configuration globbing
'module_listener_options' => [
'config_glob_paths' => [realpath(__DIR__) . '/autoload/{,*.}{global,local}-development.php'],
'config_cache_enabled' => false,
'module_map_cache_enabled' => false,
],
];
<?php
/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2014-2016 Zend Technologies USA Inc. (http://www.zend.com)
*/
/**
* List of enabled modules for this application.
*/
return [
'Zend\Db',
'Zend\Filter',
'Zend\Hydrator',
'Zend\InputFilter',
'Zend\Paginator',
'Zend\Router',
'Zend\Validator',
'ZF\Apigility',
'ZF\Apigility\Documentation',
'ZF\ApiProblem',
'ZF\Configuration',
'ZF\OAuth2',
'ZF\MvcAuth',
'ZF\Hal',
'ZF\ContentNegotiation',
'ZF\ContentValidation',
'ZF\Rest',
'ZF\Rpc',
'ZF\Versioning',
'Application',
];
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment