Hey guys,
has anyone implemented the slim framework into his app?
It looks really easy but i want to know, if there are some tricky steps
Did you use an tutorial for that?
Hey guys,
has anyone implemented the slim framework into his app?
It looks really easy but i want to know, if there are some tricky steps
Did you use an tutorial for that?
Slim is a nice framework though I prefer Silex or Phalcon. Slim is fast, but it lacks a proper documentation (It is not friendly to novice PHP developers).
On the other hand, Silex has an excellent documentation plus more than enough online examples.
For example, this is my blog post on topic of Silex: http://www.gajotres.net/best-available-php-restful-micro-frameworks/7/
But go ahead if you want to use Slim, you wonāt regret it.
P.S. I have an experience with Slim, Silex and BulletPHP. I successfully used them with Ionic and OnsenUI.
Okay, great! Thanks for your advice.
First of all i will use slim, but silex is also interesting.
I just use it for 6-8 little operations.
Okay, if there isnāt any tricky thing i try to install it
Is it right, that i could install it via composer but also manuall or is it a step-by-step installation: first install composer, than manuall?
http://docs.slimframework.com/start/get-started/
How do i integrate it, do you got an tutorial?
Best and most common way is via Composer, because this way youāll get all other dependencies (I canāt remember if there are any). Everything else is a piece of cake, you only need these two lines to start your project:
require "vendor/autoload.php";
$app = new \Slim\Slim();
Just be careful if youāre going to use an ORM. I had few problems mixing Propel with Slim/Silex.
How looks the directory strucuture with Slim?
Sorry for all my question, Iām really new with this things But i love every minute working with Ionic/Angular
Iām currently working so I canāt access my private repository but it looks something like this:
framework/
libraries/
autoload/
autoload.class.php
resource.namespaces.php
router/
tests/
router.test.php
router.class.php
resource.routes.php
configuration/
framework.configuration.php
router.configuration.php
controllers/
index.controller.php
models/
index.model.php
views/
default/
index/
index.view.php
header.view.php
footer.view.php
assets/
css/
javascript/
images/
index.php
Do i have to install Slim into the folder āappnameā or into āappname/www/ā ?
same question for ācomposerā
I always do it in a libraries/slim directory
appname/www/lib/slim
like that?
It really depends on how complex you need to make it and how you plan to maintain the code afterwards. I just stuck my 30+ services into index.php and since Iām very adept at SQL, I see no reason nor value in using ORM. But do take care in vetting SQL parameters, do use https and do use or device some auth scheme to keep the small-time crackers off your services.
Build a simple example first with say POST and GET - just to see that it all works - and then take a pencil and paper to map out your services such that they can easily be used with Angularās $resource - that should save you tons of work.
Here is one of the many links exemplifying slim: http://www.blog.iamaronbarbosa.com/building-a-basic-crud-application-using-angularjs-and-slim-php-framework-part-1/
Note that function declarations can be simplified into sumtin like:
$app->get(ā/token/:old_tokenā, function ($old_token) { ā¦ code ā¦});
Familiar to Javascript developers but maybe strange if youāre a PHP person.
Cheers
You can use any dir structure you want.
I managed to dig my last Silex project, basically I left silex in a Composer prebuilt dir:
project_folder/vendor/silex
with other dependencies.
A reason for this is, thereās no such thing as a correct project structure. Every person, team, company will have it unique solution. You should follow only one rule, it must be readable.