Skip to content

Server PHP community

Vale edited this page Mar 15, 2015 · 6 revisions

This tutorial will show you how to create a local server to host BlocklyProp.

Server installation (Xampp)

First up for getting the server up and running is downloading Xampp. Xampp is free software that installs an apache web server, a php compiler, a number of other random things you will not need, and mysql. To download Xampp, go to this link. Follow all of the installation instructions.

Running Xampp

First, find the manager application and run it. To run all of the servers that you just installed click the second tab near the top of the application. Then, click the Start All button. This will run all of the servers and allow you to run the BlocklyProp server. If the servers are running, the lights to the left of the server names should be green. If it works this way, all is well and you successfully installed Xampp!

Database configuration

Once you have Xampp installed, you must configure the database. To get to the screen to do this, you must go to your browser, and type: "localhost". If you installed Xampp correctly and are running all of the servers ( see the above section(s) if not ) this should take you to a page. To check the status of your server, click the "Status" link. This will take you to a page that will tell you what is running and what is not. It is important that everything except the PHP extensions are running. After this, you need to get to your mysql manager. Luckily, Xampp comes with a built in one that is easy to use. On the left, there should be a set of links divided in different sections. Click on the link that says "phpMyAdmin". This will take you to another page. To configure the database, you first must create a database. To do this, look on the left side of the window ( see the below picture ) and click the new button. This will take you to a screen to create the database. Enter the name of the database, and click create. Now, you will have to navigate to the database by clicking on its name ( it should be located in the same area as the picture below ). Then, click on the "Privileges" tab on the top bar and click "Add User". Enter your username, password, and change the "Host" field to "localhost". Following these actions, you will need to scroll down and click the "Go" button. If you created the user successfully, a window should pop up saying you successfully created the user.

Load database schema

After configuring the database, you must import the schema for BlocklyProp. This will setup the database for you. To do this, locate your database and click on the "import" tab. Attached to this page is a document that holds the script you need to import. Simply save this file to your computer, and upload the document to that page and click "Go". If this worked, your database should appear a little different in the left navigation panel. File: https://www.dropbox.com/s/37faf1qiztr7li7/blockly%20no%20data.sql?dl=0

Configure database connection in php

To configure the database connection in the php connection, navigate to the folder that holds the source code for BlocklyProp. Once there, go to the following location: "php/Config/". You should see a file that is named "database.php.default". You need to copy this file, paste it in this same folder, and change the name to "database.php". After this you need to edit this file. You can use whatever editor you like, but I prefer Xcode since I am on a MAC. In this file, you need to change the following fields ( only the ones that have the all-caps words in them ):

public $default = array( 'datasource' => 'Database/Mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'THE USER NAME YOU CREATED GOES HERE', 'password' => 'THE PASSWORD YOU CREATED GOES HERE', 'database' => 'THE DATABASE YOU CREATED GOES HERE', 'prefix' => '', //'encoding' => 'utf8', );

Then, save this file.

Build and deploy php-community to the server

Finally! You are just about finished and able to get on your way. All you have to do now is enter a Java editor ( I use Netbeans ) and build the PHP community file. To do this, open the project up in an IDE and then select the php-community part of the project. Build this with dependencies. Now, you have to enter the source folder for BlocklyProp. Go into the "target" folder, and copy the folder "BlocklyProp-SNAPSHOT-1.0-dist-community-php" ( you might have a slightly different name. As long as it is a folder that has a similar name it will work ). You will need to now navigate to the "htdocs" subfolder of the Xampp Application folder. If you go back to the home screen of the Xampp, manager, you can click the button "Open Application folder". This will take you to the Xampp application folder where you need to go into the "htdocs" subfolder. Once you enter this folder, paste the copied directory here.

Test out your build

If all of the previous has been followed, and you didn't receive any errors, you should be able to run BlocklyProp and get access to the community part of the project. To see if this all worked, go to your browser and type "http://localhost/Blockly/BlocklyProp-1.0-SNAPSHOT-dist-php-community/BlocklyProp-1.0-SNAPSHOT/index.html". If everything worked, a familiar page should pop up! This will look exactly like the page on the actual BlocklyProp website.