-
Notifications
You must be signed in to change notification settings - Fork 1
Installation
Index > Installation
SnooPHP and SnooPHP framework are available on Packagist.
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
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 updateYou 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 APIThe 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
-
appcontains your application code -
databasecontains table definitions -
configcontains 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. -
publicshould be the server document root. It contains theindex.phpfile which performs HTTP routing. You may place here static assets as well. -
resourcesis a multi-purpose directory that contains dynamic assets or files automatically generated (for example.cssand.jsfiles of Vue's components). Thetmpfolder contains temporary files. -
vendoris the directory created by Composer that contains required packages (i.e. the SnooPHP framework code). -
viewscontains HTML/PHP pages and/or Vue components
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
localhostas<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.