diff --git a/.gitignore b/.gitignore index 7dac201e32..37328e5390 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,7 @@ -nbproject -._* -.~lock.* -.buildpath -.DS_Store -.idea -.project -.settings +.vagrant/ +vendor/ +config/development.config.php +data/cache/* +!data/cache/.gitkeep +phpunit.xml composer.lock -vendor/bin diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 040b52eb0e..0000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "vendor/ZF2"] - path = vendor/ZF2 - url = https://github.com/zendframework/zf2.git diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000..364a6086e6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,127 @@ +# Changelog + +All notable changes to this project will be documented in this file, in reverse chronological order by release. + +## 3.1.4 - TBD + +### Added + +- Nothing. + +### Changed + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- Nothing. + +## 3.1.3 - 2019-11-27 + +### Added + +- Nothing. + +### Changed + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- [#452](https://github.com/zendframework/ZendSkeletonApplication/pull/452) provides a truly cross-platform approach to removing the `composer.lock` entry from the `.gitignore` file. The skeleton now provides a script for doing so that it invokes as part of its post-create-project-cmd event; the script removes itself on completion. + +## 3.1.2 - 2019-11-21 + +### Added + +- Nothing. + +### Changed + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- [#451](https://github.com/zendframework/ZendSkeletonApplication/pull/451) provides compatibility on Windows for the script re-instating the composer.lock in the created project. + +## 3.1.1 - 2019-11-15 + +### Added + +- Nothing. + +### Changed + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- [#449](https://github.com/zendframework/ZendSkeletonApplication/pull/449) fixes a syntax error in the post-create-project-cmd hook. + +## 3.1.0 - 2019-11-15 + +### Added + +- Nothing. + +### Changed + +- [#431](https://github.com/zendframework/ZendSkeletonApplication/pull/431) updates the skeleton to use Bootstrap 4. + +- [#428](https://github.com/zendframework/ZendSkeletonApplication/pull/428) changes the default `module_listener_options` in the `config/application.config.php` file to remove the `module_paths` and set `use_zend_loader` to false. + +- [#448](https://github.com/zendframework/ZendSkeletonApplication/pull/448) removes the `composer.lock` to ensure users creating a new project receive the latest versions of all dependencies as supported by their current PHP version. Additionally, it adds an entry to the `post-create-project-cmd` Composer hook to remove the `composer.lock` entry from the `.gitignore` file, to promote checking in a `composer.lock` in user projects. + +- [#448](https://github.com/zendframework/ZendSkeletonApplication/pull/448) bumps the version constraints of all optional packages to the latest versions supported by all PHP versions the skeleton supports. + +- [#448](https://github.com/zendframework/ZendSkeletonApplication/pull/448) bumps the minimum supported version of zf-development-mode to 3.2 + +- [#448](https://github.com/zendframework/ZendSkeletonApplication/pull/448) bumps the minimum supported version of zend-mvc to 3.1.1. + +- [#448](https://github.com/zendframework/ZendSkeletonApplication/pull/448) bumps the allowed versions of zend-component-installer to the 1.0 and 2.0 series. + +- [#448](https://github.com/zendframework/ZendSkeletonApplication/pull/448) bumps the minimum supported version of zend-skeleton-installer to 0.1.7. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- [#430](https://github.com/zendframework/ZendSkeletonApplication/pull/430) updates the `serve` command to work cross-platform, and across all supported PHP versions. diff --git a/CONDUCT.md b/CONDUCT.md new file mode 100644 index 0000000000..c663d2be93 --- /dev/null +++ b/CONDUCT.md @@ -0,0 +1,43 @@ +# 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. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..bdb281fc18 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,220 @@ +# CONTRIBUTING + +## RESOURCES + +If you wish to contribute to Zend Framework, please be sure to +read/subscribe to the following resources: + + - [Coding Standards](https://github.com/zendframework/zf2/wiki/Coding-Standards) + - [Contributor's Guide](http://framework.zend.com/participate/contributor-guide) + - ZF Contributor's mailing list: + Archives: http://zend-framework-community.634137.n4.nabble.com/ZF-Contributor-f680267.html + Subscribe: zf-contributors-subscribe@lists.zend.com + - ZF Contributor's IRC channel: + #zftalk.dev on Freenode.net + +If you are working on new features or refactoring [create a proposal](https://github.com/zendframework/ZendSkeletonApplication/issues/new). + +## Reporting Potential Security Issues + +If you have encountered a potential security vulnerability, please **DO NOT** report it on the public +issue tracker: send it to us at [zf-security@zend.com](mailto:zf-security@zend.com) instead. +We will work with you to verify the vulnerability and patch it as soon as possible. + +When reporting issues, please provide the following information: + +- Component(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 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 +``` + +You can turn on conditional tests with the `phpunit.xml` file. +To do so: + + - Copy `phpunit.xml.dist` file to `phpunit.xml` + - Edit `phpunit.xml` to enable any specific functionality you + want to test, as well as to provide test values to utilize. + +## Running Coding Standards Checks + +First, ensure you've installed dependencies via composer: + +```bash +$ composer require --dev squizlabs/php_codesniffer +``` + +To run CS checks only: + +```console +$ composer cs-check +``` + +To attempt to automatically fix common CS issues: + +```console +$ composer cs-fix +``` + +If the above fixes any CS issues, please re-run the tests to ensure +they pass, and make sure you add and commit the changes after verification. + +## Recommended Workflow for Contributions + +Your first step is to establish a public repository from which we can +pull your work into the master repository. We recommend using +[GitHub](https://github.com), as that is where the component is already hosted. + +1. Setup a [GitHub account](http://github.com/), if you haven't yet +2. Fork the repository (http://github.com/zendframework/ZendSkeletonApplication) +3. Clone the canonical repository locally and enter it. + + ```bash + $ git clone https://github.com/zendframework/ZendSkeletonApplication.git + $ cd ZendSkeletonApplication + ``` + +4. Add a remote to your fork; substitute your GitHub username in the command + below. + + ```bash + $ git remote add {username} git@github.com:{username}/ZendSkeletonApplication.git + $ git fetch {username} + ``` + +### Keeping Up-to-Date + +Periodically, you should update your fork or personal repository to +match the canonical ZF repository. Assuming you have setup your local repository +per the instructions above, you can do the following: + + +```bash +$ git checkout master +$ git fetch origin +$ git rebase origin/master +# OPTIONALLY, to keep your remote up-to-date - +$ git push {username} master:master +``` + +If you're tracking other branches -- for example, the "develop" branch, where +new feature development occurs -- you'll want to do the same operations for that +branch; simply substitute "develop" for "master". + +### Working on a patch + +We recommend you do each new feature or bugfix in a new branch. This simplifies +the task of code review as well as the task of merging your changes into the +canonical repository. + +A typical workflow will then consist of the following: + +1. Create a new local branch based off either your master or develop branch. +2. Switch to your new local branch. (This step can be combined with the + previous step with the use of `git checkout -b`.) +3. Do some work, commit, repeat as necessary. +4. Push the local branch to your remote repository. +5. Send a pull request. + +The mechanics of this process are actually quite trivial. Below, we will +create a branch for fixing an issue in the tracker. + +```bash +$ git checkout -b hotfix/9295 +Switched to a new branch 'hotfix/9295' +``` + +... do some work ... + + +```bash +$ git commit +``` + +... write your log message ... + + +```bash +$ git push {username} hotfix/9295:hotfix/9295 +Counting objects: 38, done. +Delta compression using up to 2 threads. +Compression objects: 100% (18/18), done. +Writing objects: 100% (20/20), 8.19KiB, done. +Total 20 (delta 12), reused 0 (delta 0) +To ssh://git@github.com/{username}/ZendSkeletonApplication.git + b5583aa..4f51698 HEAD -> master +``` + +To send a pull request, you have two options. + +If using GitHub, you can do the pull request from there. Navigate to +your repository, select the branch you just created, and then select the +"Pull Request" button in the upper right. Select the user/organization +"zendframework" as the recipient. + +If using your own repository - or even if using GitHub - you can use `git +format-patch` to create a patchset for us to apply; in fact, this is +**recommended** for security-related patches. If you use `format-patch`, please +send the patches as attachments to: + +- zf-devteam@zend.com for patches without security implications +- zf-security@zend.com for security patches + +#### What branch to issue the pull request against? + +Which branch should you issue a pull request against? + +- For fixes against the stable release, issue the pull request against the + "master" branch. +- For new features, or fixes that introduce new elements to the public API (such + as new public methods or properties), issue the pull request against the + "develop" branch. + +### Branch Cleanup + +As you might imagine, if you are a frequent contributor, you'll start to +get a ton of branches both locally and on your remote. + +Once you know that your changes have been accepted to the master +repository, we suggest doing some cleanup of these branches. + +- Local branch cleanup + + ```bash + $ git branch -d + ``` + +- Remote branch removal + + ```bash + $ git push {username} : + ``` + +## Conduct + +Please see our [CONDUCT.md](CONDUCT.md) to understand expected behavior when interacting with others in the project. diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..fae3669051 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM php:7.0-apache + +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 + +WORKDIR /var/www diff --git a/LICENSE.txt b/LICENSE.md similarity index 59% rename from LICENSE.txt rename to LICENSE.md index 5ad81e922d..25501b0982 100644 --- a/LICENSE.txt +++ b/LICENSE.md @@ -1,19 +1,20 @@ -Copyright (c) 2005-2014, Zend Technologies USA, Inc. +Copyright (c) 2005-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 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. +- 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. +- 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 diff --git a/README.md b/README.md index fa4f720124..8e9fc52b88 100644 --- a/README.md +++ b/README.md @@ -1,77 +1,227 @@ -ZendSkeletonApplication -======================= +# ZendSkeletonApplication -Introduction ------------- -This is a simple, skeleton application using the ZF2 MVC layer and module +> ## Repository abandoned 2019-12-31 +> +> This repository has moved to laminas/laminas-skeleton-installer. + +## Introduction + +This is a skeleton application using the Zend Framework MVC layer and module systems. This application is meant to be used as a starting place for those -looking to get their feet wet with ZF2. +looking to get their feet wet with Zend Framework. + +## Installation using Composer -Installation ------------- +The easiest way to create a new Zend Framework project is to use +[Composer](https://getcomposer.org/). If you don't have it already installed, +then please install as per the [documentation](https://getcomposer.org/doc/00-intro.md). -Using Composer (recommended) ----------------------------- -The recommended way to get a working copy of this project is to clone the repository -and use `composer` to install dependencies using the `create-project` command: +To create your new Zend Framework project: - curl -s https://getcomposer.org/installer | php -- - php composer.phar create-project -sdev --repository-url="https://packages.zendframework.com/" zendframework/skeleton-application path/to/install +```bash +$ composer create-project -sdev zendframework/skeleton-application path/to/install +``` -Alternately, clone the repository and manually invoke `composer` using the shipped -`composer.phar`: +Once installed, you can test it out immediately using PHP's built-in web server: - cd my/project/dir - git clone git://github.com/zendframework/ZendSkeletonApplication.git - cd ZendSkeletonApplication - php composer.phar self-update - php composer.phar install +```bash +$ cd path/to/install +$ php -S 0.0.0.0:8080 -t public +# OR use the composer alias: +$ composer run --timeout 0 serve +``` -(The `self-update` directive is to ensure you have an up-to-date `composer.phar` -available.) +This will start the cli-server on port 8080, and bind it to all network +interfaces. You can then visit the site at http://localhost:8080/ +- which will bring up Zend Framework welcome page. -Another alternative for downloading the project is to grab it via `curl`, and -then pass it to `tar`: +**Note:** The built-in CLI server is *for development only*. - cd my/project/dir - curl -#L https://github.com/zendframework/ZendSkeletonApplication/tarball/master | tar xz --strip-components=1 +## Development mode -You would then invoke `composer` to install dependencies per the previous -example. +The skeleton ships with [zf-development-mode](https://github.com/zfcampus/zf-development-mode) +by default, and provides three aliases for consuming the script it ships with: -Using Git submodules --------------------- -Alternatively, you can install using native git submodules: +```bash +$ composer development-enable # enable development mode +$ composer development-disable # disable development mode +$ composer development-status # whether or not development mode is enabled +``` - git clone git://github.com/zendframework/ZendSkeletonApplication.git --recursive +You may provide development-only modules and bootstrap-level configuration in +`config/development.config.php.dist`, and development-only application +configuration in `config/autoload/development.local.php.dist`. Enabling +development mode will copy these files to versions removing the `.dist` suffix, +while disabling development mode will remove those copies. -Web Server Setup ----------------- +Development mode is automatically enabled as part of the skeleton installation process. +After making changes to one of the above-mentioned `.dist` configuration files you will +either need to disable then enable development mode for the changes to take effect, +or manually make matching updates to the `.dist`-less copies of those files. -### PHP CLI Server +## Running Unit Tests -The simplest way to get started if you are using PHP 5.4 or above is to start the internal PHP cli-server in the root directory: +To run the supplied skeleton unit tests, you need to do one of the following: - php -S 0.0.0.0:8080 -t public/ public/index.php +- During initial project creation, select to install the MVC testing support. +- After initial project creation, install [zend-test](https://zendframework.github.io/zend-test/): -This will start the cli-server on port 8080, and bind it to all network -interfaces. + ```bash + $ composer require --dev zendframework/zend-test + ``` + +Once testing support is present, you can run the tests using: + +```bash +$ ./vendor/bin/phpunit +``` + +If you need to make local modifications for the PHPUnit test setup, copy +`phpunit.xml.dist` to `phpunit.xml` and edit the new file; the latter has +precedence over the former when running tests, and is ignored by version +control. (If you want to make the modifications permanent, edit the +`phpunit.xml.dist` file.) + +## Using Vagrant + +This skeleton includes a `Vagrantfile` based on ubuntu 16.04 (bento box) +with configured Apache2 and PHP 7.0. Start it up using: + +```bash +$ vagrant up +``` + +Once built, you can also run composer within the box. For example, the following +will install dependencies: + +```bash +$ vagrant ssh -c 'composer install' +``` + +While this will update them: + +```bash +$ vagrant ssh -c 'composer update' +``` + +While running, Vagrant maps your host port 8080 to port 80 on the virtual +machine; you can visit the site at http://localhost:8080/ + +> ### Vagrant and VirtualBox +> +> The vagrant image is based on ubuntu/xenial64. 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/) + +## Using docker-compose + +This skeleton provides a `docker-compose.yml` for use with +[docker-compose](https://docs.docker.com/compose/); it +uses the `Dockerfile` provided as its base. Build and start the image using: + +```bash +$ docker-compose up -d --build +``` + +At this point, you can visit http://localhost:8080 to see the site running. + +You can also run composer from the image. The container environment is named +"zf", so you will pass that value to `docker-compose run`: + +```bash +$ docker-compose run zf composer install +``` -**Note: ** The built-in CLI server is *for development only*. +## Web server setup -### Apache Setup +### Apache setup To setup apache, setup a virtual host to point to the public/ directory of the project and you should be ready to go! It should look something like below: - - ServerName zf2-tutorial.localhost - DocumentRoot /path/to/zf2-tutorial/public - SetEnv APPLICATION_ENV "development" - - DirectoryIndex index.php - AllowOverride All - Order allow,deny - Allow from all - - +```apache + + ServerName zfapp.localhost + DocumentRoot /path/to/zfapp/public + + DirectoryIndex index.php + AllowOverride All + Order allow,deny + Allow from all + + Require all granted + + + +``` + +### Nginx setup + +To setup nginx, open your `/path/to/nginx/nginx.conf` and add an +[include directive](http://nginx.org/en/docs/ngx_core_module.html#include) below +into `http` block if it does not already exist: + +```nginx +http { + # ... + include sites-enabled/*.conf; +} +``` + + +Create a virtual host configuration file for your project under `/path/to/nginx/sites-enabled/zfapp.localhost.conf` +it should look something like below: + +```nginx +server { + listen 80; + server_name zfapp.localhost; + root /path/to/zfapp/public; + + location / { + index index.php; + try_files $uri $uri/ @php; + } + + location @php { + # Pass the PHP requests to FastCGI server (php-fpm) on 127.0.0.1:9000 + fastcgi_pass 127.0.0.1:9000; + fastcgi_param SCRIPT_FILENAME /path/to/zfapp/public/index.php; + include fastcgi_params; + } +} +``` + +Restart the nginx, now you should be ready to go! + +## 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 +``` \ No newline at end of file diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000000..8d9c9932ac --- /dev/null +++ b/TODO.md @@ -0,0 +1,12 @@ +# TODO + +This is a TODO list for the feature/zend-mvc-v3-minimal branch. + +## Documentation + +- ModuleRouteListener is removed from the skeleton. This won't affect existing + users, but *will* affect experienced users who originally relied on it being + active in new skeleton projects. +- The `/[:controller][/:action]]` route was removed from the skeleton. Again, it + will not affect existing users, but *will* affect experienced users who + originally relied on it being active in new skeleton projects. diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000000..a0fbe51a51 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,56 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +VAGRANTFILE_API_VERSION = '2' + +@script = <