1 / 11

FABRIC

Introduction to. FABRIC. by Fabrizio Parrella. What is Fabric. Just another PHP framework. Built to be light, fast, no overhead. Simple configuration. in fact... none is needed. Why Fabric. Needed: Something I had full control on That could be “Drop and GO”

joben
Download Presentation

FABRIC

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to FABRIC by Fabrizio Parrella

  2. What is Fabric • Just another PHP framework • Built to be light, fast, no overhead • Simple configuration... in fact... none is needed

  3. Why Fabric • Needed: • Something I had full control on • That could be “Drop and GO” • To “normalize” PHP settings • Wanted: • Something fully OO • Flexible, able to support other packages • phpMailer, smarty, etc..

  4. What does Fabric Do for You ? • Well... nothing really :-) • It helps you to write code faster • I know you hear that before • Core separated from your Code • Heard this too • Gives you a few helpers classes • Integrates with your previous classes/projects fairly easy • Light, Light... Light... did I mention.. light ? • Just a couple files are really needed

  5. What Do You Need /web - configurable main folder/web/bin - core classes created by the developer/web/etc - configuration files (and possible other needed files) /web/etc/hooks - location for the files used with the hook class/web/etc/lang - location for the files used by the lang class/web/etc/periodic - cron files/web/include - _functions.php – loading class function/web/lib - helper classes needed by /bin/web/logs - location that can be used to store logs/web/sbin - system binary, stand alone classes/web/slib - system libraries, those files needs /bin to work/web/tmp - location that can be used to store temporary files/web/tpl - template folder/web/usr - location that can be used for user uploaded files/cron.php - cron file, simply cron it to run once every minute/index.php - generic configuration/.htaccess - a few redirects

  6. Helpers • table_prototype • uri parsing and creator • cron • exceptions • config • email • cookies/sessions/cache • etc....

  7. What do you need to know • lc() and ll() • /[s]bin and /[s]lib • /bin/path/class.php = lc('path_class') • /lib/path/class.php = ll('path_class') • /[bin|lib]/path/class.php == class path_class(){}; • {ll('class')->function();}==={$class = ll('class'); $class->function();} • ll('class')->function1()->function2()->.... ll() and lc() might be consolidated into one function as well as sbin and slib. A function will be created for sbin/slib and one for bin/lib

  8. What happens when hitting a page • .htaccess (not necessary, but it makes it prettier) • Index.php • setting up constants and other vars • include the functions file [ lc() and ll() ] • include fabric • autoload classes (URI always loaded. The rest is configurable, default: none ) • load called CLASS/TASK, or fail over if not found (usually an error page or “did you mean system”. configurable) • load 'display' and outputs the page (if any)

  9. What does the Code Look Like 1 Sample Code: www.mysite.com/home.html The extension (.html) is optional and configurable /fabric/bin/home.php <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class home{ public function __construct(){ $task = lc('uri')->get(TASK_KEY, 'home'); if(!method_exists($this,'web_'.$task) || !is_callable(array($this,'web_'.$task))){ $task = 'home'; } ll('display')->assign('task',$task); $this->{'web_'.$task}(); } public function web_home(){ $page_title = 'Home Page'; ll('display')->assign('title', $page_title); ll('display')->show('home'); } } ?> P.S.: Soon the __construct will be optional

  10. What does the Code Look Like 2 Sample Code: www.mysite.com/home.html The extension (.html) is optional and configurable /fabric/tpl/home.php <html> <head> <title><?=$title?></title> </head> <body> Welcome !! <br /><br /> The Current Task is <?=$task?>;<br /><br /> And now let's Generate a warning message <?=$nonexistent_var?><br /><br /> Let's Output All the assigned vars <?php ll('output')->debug($this->get()); //ll('output')->debug($this->get(), '_DIE'); //This will kill the page after the output ?> </body> </html> Page won't be generated until the /bin/home.php class finishes

  11. WHERE TO FIND IT ? • Soon to be posted on github. as soon as I figure out how WEBSITE ? • None yet.... planning on www.phpfabric.com WANT TO TRY IT OUT ? • email me at fabrizio@bibivu.com and I'll email you a zip file suggestions are very VERY welcome See it in action on: • www.queensboro.com • www.pbidir.com • www.storefrunt.com • www.bsdstats.org

More Related