Skip to content
This repository has been archived by the owner on Jan 1, 2020. It is now read-only.

Commit

Permalink
Merging develop to master in preparation for 3.0.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Jun 28, 2016
2 parents 57c1011 + 2eec71f commit 9bd2b26
Show file tree
Hide file tree
Showing 96 changed files with 6,780 additions and 12,902 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ nbproject
.idea
.project
.settings
vendor
vendor/
composer.phar
config/development.config.php
phpunit.xml
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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/apache2.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
196 changes: 127 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,118 +1,176 @@
ZendSkeletonApplication
=======================
# ZendSkeletonApplication

Introduction
------------
This is a simple, skeleton application using the ZF2 MVC layer and module
## 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 using Composer

The easiest way to create a new ZF2 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).
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).

To create your new Zend Framework project:

Create your new ZF2 project:
```bash
$ composer create-project -sdev zendframework/skeleton-application path/to/install
```

composer create-project -n -sdev zendframework/skeleton-application path/to/install
Once installed, you can test it out immediately using PHP's built-in web server:

```bash
$ php -S 0.0.0.0:8080 -t public/ public/index.php
```

This will start the cli-server on port 8080, and bind it to all network
interfaces.

### Installation using a tarball with a local Composer
**Note:** The built-in CLI server is *for development only*.

If you don't have composer installed globally then another way to create a new ZF2 project is to download the tarball and install it:
## Development mode

1. Download the [tarball](https://github.com/zendframework/ZendSkeletonApplication/tarball/master), extract it and then install the dependencies with a locally installed Composer:
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:

cd my/project/dir
curl -#L https://github.com/zendframework/ZendSkeletonApplication/tarball/master | tar xz --strip-components=1

```bash
$ composer development-enable # enable development mode
$ composer development-disable # enable development mode
$ composer development-status # whether or not development mode is enabled
```

2. Download composer into your project directory and install the dependencies:
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.

curl -s https://getcomposer.org/installer | php
php composer.phar install
## Running Unit Tests

If you don't have access to curl, then install Composer into your project as per the [documentation](https://getcomposer.org/doc/00-intro.md).
To run the supplied skeleton unit tests, you need to do one of the following:

Web server setup
----------------
- During initial project creation, select to install the MVC testing support.
- After initial project creation, install [zend-test](https://zendframework.github.io/zend-test/):

### PHP CLI server
```bash
$ composer require --dev zendframework/zend-test
```

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:
Once testing support is present, you can run the tests using:

php -S 0.0.0.0:8080 -t public/ public/index.php
```bash
$ ./vendor/bin/phpunit
```

This will start the cli-server on port 8080, and bind it to all network
interfaces.
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.)

**Note:** The built-in CLI server is *for development only*.
## Using Vagrant

This skeleton includes a `Vagrantfile` based on ubuntu 14.04, and using the
ondrej/php PPA to provide 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:

### Vagrant server
```bash
$ vagrant ssh -c 'composer install'
```

This project supports a basic [Vagrant](http://docs.vagrantup.com/v2/getting-started/index.html) configuration with an inline shell provisioner to run the Skeleton Application in a [VirtualBox](https://www.virtualbox.org/wiki/Downloads).
While this will update them:

1. Run vagrant up command
```bash
$ vagrant ssh -c 'composer update'
```

vagrant up
While running, Vagrant maps your host port 8080 to port 80 on the virtual
machine; you can visit the site at http://localhost:8080/

2. Visit [http://localhost:8085](http://localhost:8085) in your browser
## Using docker-compose

Look in [Vagrantfile](Vagrantfile) for configuration details.
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
```

## Web server 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:

<VirtualHost *:80>
ServerName zf2-app.localhost
DocumentRoot /path/to/zf2-app/public
<Directory /path/to/zf2-app/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
</VirtualHost>
```apache
<VirtualHost *:80>
ServerName zf2-app.localhost
DocumentRoot /path/to/zf2-app/public
<Directory /path/to/zf2-app/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
</VirtualHost>
```

### 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:

http {
# ...
include sites-enabled/*.conf;
}
```nginx
http {
# ...
include sites-enabled/*.conf;
}
```


Create a virtual host configuration file for your project under `/path/to/nginx/sites-enabled/zf2-app.localhost.conf`
it should look something like below:

server {
listen 80;
server_name zf2-app.localhost;
root /path/to/zf2-app/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/zf2-app/public/index.php;
include fastcgi_params;
}
```nginx
server {
listen 80;
server_name zf2-app.localhost;
root /path/to/zf2-app/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/zf2-app/public/index.php;
include fastcgi_params;
}
}
```

Restart the nginx, now you should be ready to go!
12 changes: 12 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -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.
37 changes: 13 additions & 24 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,25 @@
VAGRANTFILE_API_VERSION = '2'

@script = <<SCRIPT
DOCUMENT_ROOT_ZEND="/var/www/zf/public"
add-apt-repository ppa:ondrej/php
apt-get update
apt-get install -y apache2 git curl php5-cli php5 php5-intl libapache2-mod-php5
echo "
<VirtualHost *:80>
ServerName skeleton-zf.local
DocumentRoot $DOCUMENT_ROOT_ZEND
<Directory $DOCUMENT_ROOT_ZEND>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
" > /etc/apache2/sites-available/skeleton-zf.conf
apt-get install -y apache2 git curl php7.0 php7.0-bcmath php7.0-bz2 php7.0-cli php7.0-curl php7.0-intl php7.0-json php7.0-mbstring php7.0-opcache php7.0-soap php7.0-sqlite3 php7.0-xml php7.0-xsl php7.0-zip libapache2-mod-php7.0
sed -i 's!/var/www/html!/var/www/public!g' /etc/apache2/sites-available/000-default.conf
a2enmod rewrite
a2dissite 000-default
a2ensite skeleton-zf
service apache2 restart
cd /var/www/zf
curl -Ss https://getcomposer.org/installer | php
php composer.phar install --no-progress
echo "** [ZEND] Visit http://localhost:8085 in your browser for to view the application **"
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
if ! grep "cd /var/www" /home/vagrant/.profile > /dev/null; then
echo "cd /var/www" >> /home/vagrant/.profile
fi
echo "** [ZF] Run the following command to install dependencies, if you have not already:"
echo " vagrant ssh -c 'composer install'"
echo "** [ZF] Visit http://localhost:8080 in your browser for to view the application **"
SCRIPT

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'bento/ubuntu-14.04'
config.vm.network "forwarded_port", guest: 80, host: 8085
config.vm.hostname = "skeleton-zf.local"
config.vm.synced_folder '.', '/var/www/zf'
config.vm.box = 'ubuntu/trusty64'
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.synced_folder '.', '/var/www'
config.vm.provision 'shell', inline: @script

config.vm.provider "virtualbox" do |vb|
Expand Down
Loading

0 comments on commit 9bd2b26

Please sign in to comment.