Add databases to PHP 7 projects
July 31, 2017
- You must have a gorilla.com user.
- You must have got installed Docker, GorillaJS and the DB for PHP7 plugin.
$ gorilla plugin add db_php7
$ gorilla plugin remove db_php7
How to use it
To use the DB plugin for PHP7 you have to create a new project, select the PHP7 installer and choose one of the three kind of database which are in the options selector.
If you select no option and you need to select later a database, you’ll have to command again the project passing the parameter -f.
Don’t forget that GorillaJS always uses the port which is in the official documentation of each engine. The hosts name is created with the domain name you had chosen for your project plus the technology name ahead by a “_”
Here you have some php examples of database connections for each engine.
$connection = mysqli_connect("yourproject.local_mysql", "yourusername", "yourdatabasepassword", "yourdatabasename");
$connection = pg_connect("host=yourproject.local_postgresql dbname=yourdatabasename user=yourusername password=yourdatabasename");
$manager = new MongoDB\Driver\Manager("mongodb://yourusername:email@example.com_mongo/yourdatabasename");
The NodeJS template that comes as a default in GorillaJS uses the Express.js framework to start a server and return a response. This is optional, and once the application is running we can eliminate this server and use the application in any other way.
Why do you need to free the port 80? Can you make your own installers? Can you use GorillaJS in a remote server?