Zend Framework - quick tutorial (part 2)

Categories: featured, web development, zend framework
Zend Framework - quick tutorial (part 2)

Directory Layout and Bootstrapping. When someone starts with the learning of a framework, first he begins to read various articles to understand the basic rules to work with. There are a lot of tutorials how exactly to start, and there is also an official quick start guide, but beside this there are too much advices how should you directory layout look like. For me the following directory layout is working well. I don't remember exactly where I've found it, but I think many people use it. application admin controllers models views content controllers models views layouts bootstrap.php config.ini library Zend public index.php Almost half of the sources "how to start" recommend all of the initialization should be in index.php in the public folder. In fact all the logic of the public/private folders is that we don't like to show anything on the web, and that's why index.php contains only the following peace of code (it's recommended to leave the file open from the ?> closing tag): <?php require '../application/bootstrap.php'; Anything else, all the initialization is in bootstrap.php: error_reporting (E_ALL | E_STRICT); ini_set ('display_startup_errors', 1); ini_set ('display_errors', 1); set_include_path ('../library' . PATH_SEPARATOR . get_include_path()); require_once "Zend/Loader.php"; Zend_Loader::registerAutoload(); $front = Zend_Controller_Front::getInstance(); $front->throwExceptions(true); $front->setControllerDirectory(array('default' => '../application/content/controllers', 'admin'   => '../application/admin/controllers')); $front->dispatch(); We set the error reporting to be ON, which si good when you develop any application and to collect all error messages. Than add the library folder in ...

Zend_Layout

Categories: featured, web development
Zend_Layout

Или как да не пишем във всеки шаблон, че ще има header. Всеки, който започва да използва нов web framework първоначално се запитва за няколко основни неща. Като цяло те и отговарят на MVC практиката. Как да направим така че всичките ни състояния в сайта да бъдат описани в различни файлове, така че да можем лесно да си намираме и поддържаме кода. Как да се погрижим за правата и ролите на различните потребители на сайта. Как да разделим html-а на няколко файла, за да не пишем по един милион пъти includes на header или footer. Почти всеки, който се е сблъсквал с PHP програмиране е чувал за Smarty и когато някой, по-често псевдо разбирач, ти изреди една плеяда колко е ретроградно да се слага php код измежду html таговете и как трябвало Smarty да се притече на помощ, ето един добър довод за излагане против Smarty. Хубаво е да се ползва Smarty. Няма проблем. Само че нека си представим следния пример. Имаме сайт с header - content - footer. Като обикновено header-a съдържа разни връзки към css и meta тагове. Със Smarty като искаме да използваме тая структура за 10 файла, 10 пъти ще имаме следния код: {include file="header.tpl"} {include file="content.tpl"} {include file="footer.tpl"} и ако това се повтаря в 100 ...

Perl Regular Expressions

Categories: featured, web development
Perl Regular Expressions

For everyone who did write a code someday comes the question of using regular expressions. Almost everybody has heart about automatic and regular languages. Assume you have all word for a given languages, which means all possible combination between the letters of a given alphabet. For all these possible word only few construct the "language" as we know this term. Of course there's also need of grammatic, etc. But however we have the set of words in a given language. Than comes the task to find those of the words of the language that match a given condition. In fact the regular expressions are a powerful tool to do this job. Using PHP you can use preg_ functions, which will perform a perl regular expressions match. In my case I had to find in about 180 .html files specific words. Assume the files contain something like: <!-- wellformed html comment --> <tr> <td class="classname1"><img ...></td> <td class="classname2"> <a ... > Word to match </a> </td> </tr> <tr> <td ...></td> <td ...></td> </tr> <!--wellformed html comment--> The regular expressions for preg_replace function I used was something like this: '/^[t|s]*<tr>.*?$n^.*?<td.*?</td>.*?$n.*? <td.*?$n.*?<a.*?>.*?$n.*?Word to match.*?$n.*?</a>.*$n.*?</td>.*$n.*? </tr>.*$n.*?<tr.*$n.*?<td.*$n.*?<td.*$n.*?</tr>/m' ... and it worked for me. In fact if you use 's' instead of 'm' modifier that's gonna be you mistake cause of the multiple matches before ...

stoimen.com/blog

web developing

Featured & Popular Articles