Proyectos de Subversion LeadersLinked - Services

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
# laminas-mvc-skeleton
2
 
3
## Introduction
4
 
5
This is a skeleton application using the Laminas MVC layer and module
6
systems. This application is meant to be used as a starting place for those
7
looking to get their feet wet with Laminas MVC.
8
 
9
## Installation using Composer
10
 
11
The easiest way to create a new Laminas MVC project is to use
12
[Composer](https://getcomposer.org/). If you don't have it already installed,
13
then please install as per the [documentation](https://getcomposer.org/doc/00-intro.md).
14
 
15
To create your new Laminas MVC project:
16
 
17
```bash
18
$ composer create-project -sdev laminas/laminas-mvc-skeleton path/to/install
19
```
20
 
21
Once installed, you can test it out immediately using PHP's built-in web server:
22
 
23
```bash
24
$ cd path/to/install
25
$ php -S 0.0.0.0:8080 -t public
26
# OR use the composer alias:
27
$ composer run --timeout 0 serve
28
```
29
 
30
This will start the cli-server on port 8080, and bind it to all network
31
interfaces. You can then visit the site at http://localhost:8080/
808 stevensc 32
 
1 efrain 33
- which will bring up Zend Framework welcome page.
34
 
808 stevensc 35
**Note:** The built-in CLI server is _for development only_.
1 efrain 36
 
37
## Development mode
38
 
39
The skeleton ships with [laminas-development-mode](https://github.com/laminas/laminas-development-mode)
40
by default, and provides three aliases for consuming the script it ships with:
41
 
42
```bash
43
$ composer development-enable  # enable development mode
44
$ composer development-disable # disable development mode
45
$ composer development-status  # whether or not development mode is enabled
46
```
47
 
48
You may provide development-only modules and bootstrap-level configuration in
49
`config/development.config.php.dist`, and development-only application
50
configuration in `config/autoload/development.local.php.dist`. Enabling
51
development mode will copy these files to versions removing the `.dist` suffix,
52
while disabling development mode will remove those copies.
53
 
808 stevensc 54
Development mode is automatically enabled as part of the skeleton installation process.
1 efrain 55
After making changes to one of the above-mentioned `.dist` configuration files you will
56
either need to disable then enable development mode for the changes to take effect,
57
or manually make matching updates to the `.dist`-less copies of those files.
58
 
59
## Running Unit Tests
60
 
61
To run the supplied skeleton unit tests, you need to do one of the following:
62
 
63
- During initial project creation, select to install the MVC testing support.
64
- After initial project creation, install [laminas-test](https://docs.laminas.dev/laminas-test/):
65
 
66
  ```bash
67
  $ composer require --dev laminas/laminas-test
68
  ```
69
 
70
Once testing support is present, you can run the tests using:
71
 
72
```bash
73
$ ./vendor/bin/phpunit
74
```
75
 
76
If you need to make local modifications for the PHPUnit test setup, copy
77
`phpunit.xml.dist` to `phpunit.xml` and edit the new file; the latter has
78
precedence over the former when running tests, and is ignored by version
79
control. (If you want to make the modifications permanent, edit the
80
`phpunit.xml.dist` file.)
81
 
82
## Using Vagrant
83
 
84
This skeleton includes a `Vagrantfile` based on ubuntu 18.04 (bento box)
85
with configured Apache2 and PHP 7.3. Start it up using:
86
 
87
```bash
88
$ vagrant up
89
```
90
 
91
Once built, you can also run composer within the box. For example, the following
92
will install dependencies:
93
 
94
```bash
95
$ vagrant ssh -c 'composer install'
96
```
97
 
98
While this will update them:
99
 
100
```bash
101
$ vagrant ssh -c 'composer update'
102
```
103
 
104
While running, Vagrant maps your host port 8080 to port 80 on the virtual
105
machine; you can visit the site at http://localhost:8080/
106
 
107
> ### Vagrant and VirtualBox
108
>
109
> The vagrant image is based on bento/ubuntu-18.04. If you are using VirtualBox as
110
> a provider, you will need:
111
>
112
> - Vagrant 2.2.6 or later
113
> - VirtualBox 6.0.14 or later
114
 
115
For vagrant documentation, please refer to [vagrantup.com](https://www.vagrantup.com/)
116
 
117
## Using docker-compose
118
 
119
This skeleton provides a `docker-compose.yml` for use with
120
[docker-compose](https://docs.docker.com/compose/); it
121
uses the `Dockerfile` provided as its base. Build and start the image using:
122
 
123
```bash
124
$ docker-compose up -d --build
125
```
126
 
127
At this point, you can visit http://localhost:8080 to see the site running.
128
 
129
You can also run composer from the image. The container environment is named
130
"laminas", so you will pass that value to `docker-compose run`:
131
 
132
```bash
133
$ docker-compose run laminas composer install
134
```
135
 
136
## Web server setup
137
 
138
### Apache setup
139
 
140
To setup apache, setup a virtual host to point to the public/ directory of the
141
project and you should be ready to go! It should look something like below:
142
 
143
```apache
144
<VirtualHost *:80>
145
    ServerName laminasapp.localhost
146
    DocumentRoot /path/to/laminasapp/public
147
    <Directory /path/to/laminasapp/public>
148
        DirectoryIndex index.php
149
        AllowOverride All
150
        Order allow,deny
151
        Allow from all
152
        <IfModule mod_authz_core.c>
153
        Require all granted
154
        </IfModule>
155
    </Directory>
156
</VirtualHost>
157
```
158
 
159
### Nginx setup
160
 
161
To setup nginx, open your `/path/to/nginx/nginx.conf` and add an
162
[include directive](http://nginx.org/en/docs/ngx_core_module.html#include) below
163
into `http` block if it does not already exist:
164
 
165
```nginx
166
http {
167
    # ...
168
    include sites-enabled/*.conf;
169
}
170
```
171
 
172
Create a virtual host configuration file for your project under `/path/to/nginx/sites-enabled/laminasapp.localhost.conf`
173
it should look something like below:
174
 
175
```nginx
176
server {
177
    listen       80;
178
    server_name  laminasapp.localhost;
179
    root         /path/to/laminasapp/public;
180
 
181
    location / {
182
        index index.php;
183
        try_files $uri $uri/ @php;
184
    }
185
 
186
    location @php {
187
        # Pass the PHP requests to FastCGI server (php-fpm) on 127.0.0.1:9000
188
        fastcgi_pass   127.0.0.1:9000;
189
        fastcgi_param  SCRIPT_FILENAME /path/to/laminasapp/public/index.php;
190
        include fastcgi_params;
191
    }
192
}
193
```
194
 
195
Restart the nginx, now you should be ready to go!
196
 
197
## QA Tools
198
 
199
The skeleton does not come with any QA tooling by default, but does ship with
200
configuration for each of:
201
 
202
- [phpcs](https://github.com/squizlabs/php_codesniffer)
203
- [phpunit](https://phpunit.de)
204
 
205
Additionally, it comes with some basic tests for the shipped
206
`Application\Controller\IndexController`.
207
 
208
If you want to add these QA tools, execute the following:
209
 
210
```bash
211
$ composer require --dev phpunit/phpunit squizlabs/php_codesniffer zendframework/zend-test
212
```
213
 
214
We provide aliases for each of these tools in the Composer configuration:
215
 
216
```bash
217
# Run CS checks:
218
$ composer cs-check
219
# Fix CS errors:
220
$ composer cs-fix
221
# Run PHPUnit tests:
222
$ composer test
223
```