Get Started
Welcome to Silex-MVC!
This application is a teaching example of a design pattern MVC based on the SILEX (the PHP micro-framework based on the Symfony2 Components). The purpose of this application is to show the use of some capabilities SILEX micro-framework, and the use of other technologies. Installation examples are for Windows and web server Nginx.
To start working with this application you need to perform some steps:
- Must be met preliminary requirements
- Download and install
Silex-MVC
- Configure a local web server, to the entry point was
public/index.php
- Open site in a browser
Prerequisites
Download and install Silex-MVC
Go to GitHub with our project.
Clone or download the project to the appropriate folder (for example c:/NginxServer/html/silex-mvc
).
Go to the folder where the application was installed and run from a console command composer install
For the operation of the application you need to create a database with the appropriate data.
To do this, from the console run command file app/Console/scripts/orm/schema_create.bat
.
Configure web server
Install, if necessary, the appropriate permissions to write to the path/to/project/var
Depending on the type of possible different configurations of web server.
For example, for the server Nginx
possible this configuration file nginx.conf
:
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
# File size for upload
client_max_body_size 1024m;
client_body_timeout 120s;
client_body_buffer_size 128k;
upstream backend {
server 127.0.0.1:9000;
}
server {
listen 8080;
server_name localhost;
root html/;
location / {
index index.html index.php;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
server {
listen 8080;
server_name ~^(?<domain>.+);
gzip on;
ssi off;
root html/$domain/public;
location @phpfcgi {
internal;
fastcgi_buffers 16 16k;
include fastcgi_params;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param SCRIPT_NAME /index.php;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
}
location ~ \.(php|php/.*)$ {
fastcgi_buffers 16 16k;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
}
If you have a server Apache
, it is possible tohttpd.conf
create a virtual host, such as:
NameVirtualHost *:8080
# localhost
<VirtualHost *:8080>
ServerName localhost
DocumentRoot "C:/Xampp/htdocs"
</VirtualHost>
# silex-mvc
<VirtualHost *:8080>
ServerName silex-mvc
DocumentRoot "C:/Xampp/htdocs/silex-mvc/public"
ServerAdmin webmaster@read.local
<Directory "C:/Xampp/htdocs/silex-mvc/public" >
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
The Apache
server must support mode mod_rewrite
.
You should also make sure that Apache
configured to support .htaccess
files.
File of .htaccess
must be in the public/
folder. The contents of the file .htaccess
may look so:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
For Windows in the file c:\Windows\System32\drivers\etc\hosts
necessary to prescribe
127.0.0.1 silex-mvc
If you are using a proxy, it is necessary in the parameters of the proxy server in the section
Do not use proxy server for addresses beginning with
to prescribe our address
...;silex-mvc
Open site in a browser
Make sure that the web server is running. Enter in your browser for example this address: http://silex-mvc:8080/