Idea Transcript
Utilizing php and Aptana for Semester Project Items to download
- XAMPP • XAMPP includes: Apache, PHP, MySQL, and other goodies. No need to download and install them separately, XAMPP does it all.
• Download: https://www.apachefriends.org/download.html • FAQs (Includes instructions on how to install it and set it up): - Windows FAQs: https://www.apachefriends.org/faq_windows.html - OSX FAQs: https://www.apachefriends.org/faq_osx.html - Linux FAQs: https://www.apachefriends.org/faq_linux.html - Aptana Studio • Aptana Studio is a web development IDE rooted on Eclipse. You can use your preferred IDE for the project, it does not need to be Aptana.
• Download: http://www.aptana.com/products/studio3/download.html • You can download Aptana Studio 3. For the instructions on this guide, we will use the standalone (not the Eclipse plugin) version of Aptana Studio 3.
- Sample API (Slim Framework) • Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
• Slim Framework documentation: http://docs.slimframework.com/ • Download sample API: http://www.engr.uconn.edu/~steve/Cse4701/sample_api.zip - Sample GUI Web-App (for CRUD operations) • A sample CRUD (Create, Read, Update, Delete) web-app that interfaces with the MySQL database we will be using.
• Download sample API: http://www.engr.uconn.edu/~steve/Cse4701/sample_gui.zip
1
Utilizing php and Aptana for Semester Project 1.
Setting up a Sample Database
Creating and setting a database is extremely easy with XAMPP. XAMPP bundles in PhpMyAdmin (http://www.phpmyadmin.net/home_page/index.php), a web-app that interfaces with the MySQL installation and allows you to manage all databases found on your machine. To create a sample database, make sure Apache and MySQL are running in the XAMPP Control Panel. It looks something like this:
Just make sure to click start on Apache and MySQL. The second step is to go to your PhpMyAdmin web-app. Simply open any browser and go to: http://localhost/phpmyadmin (or click this link!). If you are running your Apache instance in another port other than the traditional 80, just go to http://localhost:{yourport}/phpmyadmin; where {yourport} is the custom port. When you go to your PhpMyAdmin web-app, you will see something like this:
2
Utilizing php and Aptana for Semester Project
You are ready to set a database. The steps are as follows:
- Click Databases on the top-left. - Give a name to the database and click create. For this guide, we will give it the name sample
- Create a table called sample_data with 3 columns: id (the primary key, autoincrement), name, address. This table will hold a set of names with tied addresses, each with its unique identifier. We are now ready to deploy our sample API.
3
Utilizing php and Aptana for Semester Project 2.
Setting up the Sample API
To set the Sample API (download at: —), first you need to add it to your XAMPP’s htdocs folder. This folder is located on the installation path of your XAMPP (e.g. C:/xampp/htdocs). Copy and paste the folder, called sample_api, into htdocs. You should have something that looks like C:/xampp/htdocs/sample_api; where all the Slim framework files including the actual code in the index.php can be found. At this point you should be able to test it. With Apache and MySQL running, go to http://localhost/sample_api; you should see the PHP information (the result of a ). If you do, you are pretty much set! With the sample_api folder in place, we are now ready to open Aptana Studio to ‘create’ our project. The steps are as follows:
- Open Aptana Studio (or your IDE) - Click File -> Import - Select Existing Folder as New Project - Select a folder. Navigate to your C:/xampp/htdocs/sample_api folder - Give the project a name - Select PHP and Web - Primary as the project types - Click on Finish You should now be able to see the project on the project navigator on the left. Expand the project and go to the index.php file. You will see some sample code. First, you will see the $app->get(‘/‘, function() { … }); method with the phpinfo(); inside. This is the code that gets executed when you go to your root of sample_api on your browser. Below that you will see a similar method, but with a /names route. This route is executed when you do a GET request to http://localhost/sample_api/names. Make sure the username and password for the database are correctly set, and if you had any data on the database, you would see a JSON with the key-value pairs for the names stored. To insert, update or delete items on the database through the sample_api, you will need to create POST, PUT, and DELETE routes. Refer to the Slim framework documentation (http://docs.slimframework.com/) on examples of how to do so.
4
Utilizing php and Aptana for Semester Project 3.
Deploying the web-app for CRUD operations
To deploy the web-app for CRUD operations, just download (—) and copy the folder to the htdocs folder in your machine. Once this is done, and assuming Apache and MySQL are running in your XAMPP control panel, you can visit the folder via your browser to see the operations. This web-app is just a really simple piece of code that adds and deletes items from the database. In case you need to do more, you can use PhpMyAdmin (bundled with the XAMPP installation).
5