Skip to content

Installation

Andrea Mecchia edited this page Jul 4, 2018 · 5 revisions

Index > Installation


SnooPHP and SnooPHP framework are available on Packagist.

version

Installation

It is recommended you create a new project using the create-project Composer command:

~$ composer create-project snoophp/snoophp <project-dir>

Composer is a very popular package manager for PHP

Manual installation

Alternatively you can clone the project repository using git:

$ git clone https://github.com/snoophp/snoophp.git <project-dir>

However you will still need Composer to install required dependencies:

$ cd <project-dir>
$ composer update

Using third-party libraries

You can use Compose to install third-party libraries with the require command:

$ composer require intervention/image # A popular image manipulation library
$ composer require sendgrid/sendgrid # Access to the SendGrid API

Project setup

The project directory looks like this:

.
├── app
├── database
├── config
├── public
├── resources
│   └── tmp
├── vendor
├── views
├── bootstrap.php
├── composer.json
├── composer.lock
├── LICENSE.md
├── README.md
└── webhook.sh
  • app contains your application code
  • database contains table definitions
  • config contains general configuration files, database configuration and route definitions. In general you can place here any file that you want to automatically load at the start.
  • public should be the server document root. It contains the index.php file which performs HTTP routing. You may place here static assets as well.
  • resources is a multi-purpose directory that contains dynamic assets or files automatically generated (for example .css and .js files of Vue's components). The tmp folder contains temporary files.
  • vendor is the directory created by Composer that contains required packages (i.e. the SnooPHP framework code).
  • views contains HTML/PHP pages and/or Vue components

Setting up the database connection

SnooPHP doesn't handle database creation, so you will need to either already have a database created or create a new one:

Note: MySQL is officialy supported. Other SQL DBMS may not work with specific features, like migration.

create database <db-name>;
create user <db-user>@<domain> identified by <db-password>;
grant all on <db-name>.* to <db-user>@<domain>;

If the database runs on the same machine of the server you can use localhost as <domain>

SnooPHP allows to define multiple connections. By default, the master connection is commented out. Remove the multi-line comment and fill in the master connection with your credentials:

"master"	=> [
	"protocol"	=> "mysql",
	"host"		=> "<db-host>",
	"schema"	=> "<db-name>",
	"username"	=> "<db-user>",
	"password"	=> "<db-password>",
	"params"	=> [
		PDO::ATTR_ERRMODE	=> PDO::ERRMODE_EXCEPTION
	]

In "params" You can specify PDO options for the connection. It is recommended to run PDO with PDO::ERRMODE_EXCEPTION enabled.

You can also specify other connections. For example you may have different databases on separate machine to balance the traffic load:

"remote_1"	=> [
	...
],
"remote_2"	=> [
	...
]

The only fully-supported DBMS is MySQL. Other SQL DBMS may prevent you from using specific features, such as migrations, even though basic query should work anyway.

The database interface of SnooPHP is built around the PDO library and focuses on SQL databases, thus potentially any SQL DBMS supported by PDO may work with basic queries.


HTTP routing >

Clone this wiki locally