Download the PHP package makusu/silex-skeleton-rest without Composer
On this page you can find all versions of the php package makusu/silex-skeleton-rest. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download makusu/silex-skeleton-rest
More information about makusu/silex-skeleton-rest
Files in makusu/silex-skeleton-rest
Package silex-skeleton-rest
Short Description This skeleton / boilerplate is built using Silex for general ReSTful (API) purposes.
License MIT
Homepage http://github.com/makusu/silex-skeleton-rest
Informations about the package silex-skeleton-rest
Silex Skeleton ReSTful
Description
This skeleton (you can also call it boilerplate now) is built using Silex for general ReSTful (API) purposes.
Background
The very reason that this code exists is because I was having a hard time finding a good EXAMPLE on utilizing Silex for real life usage. I need a maintainable and testable code that made especially for API.
Of course there are many good slides and information out there, but most are just giving piece by piece explanation.
I'm not a good reader. I need an EXAMPLE!
FAQ
"Dude, you can design silex however you want. That's the beauty of it."
- "Yes, I know. But I want a nice, solid framework out of it."
"Why don't you just use Symfony2 then?"
- "Too much" (Don't miss understand me. I like Symfony2, I use it for some of my projects. But let's be honest, it's just too bulky sometimes.)
"Is this code actually working?"
- "Yeap. I use it for some smaller projects of mine. In fact, I use this more than Symfony2 I can say."
"Enough chit-chat! Show me!"
- "Here!"
What you need to know
- PHP
- Silex
- Doctrine
- Composer
- PHPUnit & DBUnit (Optional)
Installation
You can do the conventional way which is clone this repository, or the easiest way, you can just directly download composer (if you don't have it yet) here:
http://getcomposer.org/download/
After the download is complete, you can start installing the required package by running this command:
You can add option "--dev" behind if you want to have the controller test working properly.
For this test, you need to put this sql command in MySQL.
Why do we need to have 2 same database? It's not compulsory. The idea is just to differentiate between our development and our test database environment.
Change the configurations to suit your environment. Don't worry, it's simple.
- app/config/dev.php
- app/config/prod.php
- app/config/test.php
- Copy app/phpunit.xml.dist into app/phpunit.xml, and take a look at the
environment at the bottom of the file - Your server configuration must be pointing to: web/index.php (prod) and web/index_dev.php (dev)
If everything has been installed & configured properly, try to put this url in your browser:
http://silex-skeleton-rest/item
You should see this result:
Try also put this in your url:
http://silex-skeleton-rest/item/1
http://silex-skeleton-rest/item/2
If you can see a nice json result out of it, you can try to use http method POST, PUT and DELETE to manipulate the database using your api.
Finally, for testing purposes, you can just run this command at your main directory:
Final
Take your time and look around the code to understand more and do not hesitate to let me know if you have an idea how to improve this.
You're ready to go! Enjoy!