PHP is Now
Lots of people asks the question why php, i guess this article titles "PHP is Now" by Cal Evans is the Director of the PHP Center for Expertise at Ibuildings, will help those who asks, to know what is the powers of this great tool.
article URL: http://www.ibuildings.com/blog/archives/1554-PHP-is-NOW.html
Why using PHP ?
PHP is one of the most popular server side scripting languages running today. It is used for creating dynamic WebPages that interact with the user offering customized information. PHP offers many advantages; it is fast, stable, secure, easy to use and open source (free).
Rasmus Lerdorf wrote the first PHP (first called Personal Home Page) scripts as a series of Perl scripts that he used to track visitors to his webpage and to see who was viewing his resume. He eventually rewrote PHP as a scripting engine and added support for forms. PHP has been evolving since 1994 as an open source code. A community of followers and developers formed and began using and further developing PHP. Over the years the Personal Home Page acronym was dropped and it evolved into the PHP Hypertext Preprocessor.
PHP code is inserted directly into the HTML that makes up a website. When a visitor comes to the website, the code is executed. Because PHP is a server side technology, the user does not need any special browser or plug-ins to see the PHP in action.
The beauty of PHP lies in its simplicity. It is easy to understand and learn, especially for those with backgrounds in programming such as C, JavaScript and HTML. The language is similar to C and Perl so that anyone with a background in either C or Perl programming will feel comfortable using and understanding PHP. PHP also runs on just about every platform including most UNIX, Macs and Windows versions.
PHP doesn’t use a lot of the system resources so it runs fast and doesn’t tend to slow other processes down. It is typically used as an Apache module, written in C, so it loads and executes quickly. It works well with other software and can be quite fast. PHP is also stable and since it is open source, the PHP community works together to fix any bugs. The community offers technical support and continuously updates the code further expanding PHP’s capabilities.
PHP offers many levels of security to prevent malicious attacks.
Another key advantage of PHP is its connective abilities. PHP uses a modular system of extensions to interface with a variety of libraries such as graphics, XML, encryption, etc. In addition, programmers can extend PHP by writing their own extensions and compiling them into the executable or they can create their own executable and load it using PHP’s dynamic loading mechanism.
In addition to extensions, PHP has tons of server interfaces, database interfaces and other modules available. Of the server interfaces, PHP can load into Apache, Microsoft IIS, Roxen, THTTPD and AOLserver. It can also be run as a CGI module. Database interfaces are available for MySQL, Microsoft MS SQL, Informix, Oracle and plenty of others. If a database is not supported, ODBC is an option.
The main PHP source repository is loaded with modules and interfaces that users have written and contributed. There you can find modules for flash movies, PDF files, calendars and more.
A huge advantage that PHP offers is its community. Since PHP is an open source project, the PHP community is willing to share.
PHP is the best choice for developing WebPages & Intranet applications, it is compatible with any database, and web servers, and integrates well across many platforms and with various software
programs.
Below is a diagram from Oracle.com comparing between PHP & ASP.net

For the above reasons this is why i choose and recommend for you PHP as its primary language for Web Space & Intranet Applications.
Links:
www.php.net - The official PHP website
www.zend.com - The PHP Company
Framework.zend.com - Zend framework
www.zendcon.com - Zend Conference Official website
Smart Debugging with Zend Framework
Sometimes your clients report to you Errors you have never experienced while testing your web application, or broken links, or some errors that occurs under some scenarios that you didn't apply.
There is a smart trick i do in the ErrorController in my Zend Framework applications, i make the application send me the same error it displays to the user direct to my email, so i can know under what circumstances and conditions that error occurred.
The sweet thing is that when google bot or any search engine crawls my websites, they find some errors also, errors that i and the client didn't reach, so i get the chance to fix it before any body see it.
I also sometimes disable viewing the error message and display "Some errors has occurred and the support has been notified, sorry for the inconvenience" and provide a link to go to Homepage for example.
Below is the code i have in my ErrorController :
$errors = $this->_getParam('error_handler'); switch ($errors->type) { case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: // 404 error -- controller or action not found $this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found'); $this->view->title = 'HTTP/1.1 404 Not Found'; break; default: // application error; display error page, but don't change // status code $this->view->title = 'Application Error'; break; } $body = 'HTTP/1.1 404 Not Found' . "<br>"; $body .= $errors->exception . "<br>"; $body .= "IP Address: " . $_SERVER['REMOTE_ADDR'] . "<br>"; $body .= "User Agent: " . $_SERVER['HTTP_USER_AGENT'] . "<br>"; $body .= "Lang: " . $_SERVER['HTTP_ACCEPT_LANGUAGE'] . "<br>"; $body .= "Referer Link: " . $_SERVER['HTTP_REFERER'] . "<br>"; $body .= "Requested URL" . $_SERVER['REQUEST_URI'] . "<br>"; $mail = new Zend_Mail(); $mail->setBodyHtml($body); $mail->setFrom('support@somesite.com', 'Website Support'); $mail->addTo("ahmed.abdelaliem@mysite.com.com", "Ahmed Abdel-ALiem"); $mail->setSubject('Sitename Error Occurred'); $mail->send(); $this->view->message = $errors->exception;
Build MySQL insert Query from Array that contains fields and values
The following function takes table name, and array where its keys are the table fields and it's values are the values to insert in each field, it constructs the MySQL Query based on the input and executes it to insert the data.
function insertRow($table_name, $input_array){ $link = mysql_connect(SERVER, USER, PASS); mysql_select_db(DATABASE, $link); $SQL = "INSERT INTO $table_name "; $fields = "("; $values = "("; foreach ($input_array as $k => $v) { $fields .= "`$k` ,"; $values .= "'$v' ,"; } $fields .="#"; $values .="#"; $fields = explode(",#", $fields); $fields = $fields[0]; $values = explode(",#", $values); $values = $values[0]; $fields .= ")"; $values .= ")"; $SQL .= $fields . " VALUES " . $values; mysql_query($SQL); mysql_close($link); }
List array Recursively in PHP
Code :
function listArrayRecursive($array_name, $ident = 0){ if (is_array($array_name)){ foreach ($array_name as $k => $v){ if (is_array($v)){ for ($i=0; $i < $ident * 10; $i++){ echo " "; } echo $k . " : " . "<br>"; listArrayRecursive($v, $ident + 1); }else{ for ($i=0; $i < $ident * 10; $i++){ echo " "; } echo $k . " : " . $v . "<br>"; } } }else{ echo "Variable = " . $array_name; } }
Usage :
$ages = array( "ahmed" => "25", "mohamed" => "35", "group" => array("omar" => "15", "abdalla" => "20", "sub group" => array("john" => "10", "peter" => "20"))); listArrayRecursive($ages);
Output will be printed array in indented way.
Render Nothing in Zend Framework
This is useful if u want to have the output without rendering a view or the layout, like in ajax or developing we services
to do that you need to call the following 2 methods in your Action :
$this->_helper->viewRenderer->setNoRender(); // Disable the viewscript $this->_helper->layout->disableLayout(); // Disable the layout
Zend Framework Free Book : Surviving The Deep End
Hey folks,
today Padriac Brady has released a new Zend Framework Book,
About the author :
http://www.survivethedeepend.com/zendframeworkbook/en/1.0/introduction#zfbook.introduction.me
To read the book :
http://www.survivethedeepend.com/zendframeworkbook/en/1.0
About the book (quoted from the book):
Zend Framework: Surviving The Deep End is written in the form of a detailed tutorial following a step by step approach to building a real life application. Topics are grouped where it makes sense and there will be continual references to earlier chapters which serves to reinforce what you're learning as you read. The book was designed to bring together elements of the Reference Guide, the growing body of community knowledge and my own personal experience so developers can see the bigger picture of developing a real application with the Zend Framework.No comments
To my mind that's always been the framework's main problem since the Reference Guide adds little beyond explaining each framework component in total isolation. It doesn't offer a development approach, ways of thinking or a list of advanced topics which combine components. You should note though that this book is not a replacement for the Zend Framework Reference Guide. It's assumed you can do some independent reading of the Reference Guide. The Guide is free, detailed, and reasonably easy to search. This book is a complement to it, not a replacement.No comments
The book also includes the full source code of the application within the text, and may repeat it several times to highlight new changes I am making. I understand that pages of source code can sometimes be frustrating but it does enforce clarity and I value clarity a great deal. For simplicity the full finalised source code of each chapter is available as a separate internet download.No comments
I will over time refer to several external libraries, other than the Zend Framework, which you are expected to install. These will include PEAR, Blueprint CSS Framework, jQuery, HTMLPurifier and PHPUnit. I know from experience this can be unpopular with some people but I assure you that their installation will be covered in detail and is quite straightforward even for beginners. You should bear in mind a real life application will require numerous external libraries!No comments
Finally, note that this book assumes a basic working knowledge of PHP 5, SQL, and Object Oriented Programming (OOP). These are necessary skills if you intend learning the Zend Framework but will not be covered by this book in detail. Since PHP is so simple to learn though, I don't doubt you can find countless resources online to get you started down the road towards PHP Guru status.
----------------------
enjoy reading
To read the book :
Appcelerator :: Building RIA Apps and Use Cases with ease
Yesterday i was browsing Zend Framework Webinars, and i stopped by the title :
Get "Rich" Quick : Building Ajax-based RIAs with the Zend Framework and Appcelerator
i didn't hear about the Appcelerator thing before, but the title was really interesting as i use Zend framework extensively and it is a great idea to add some interactivity and UI to my apps.
after watching the webinars, i really liked the idea of being able to build the full prototype and have it working with no server side code, and then in the development phase with some slight changes to the prototype, it becomes the working front end interacting with the server side code with no problems @ all.
i went to try.appcelerator.org and gave it a try on the fly, that got me more interested. so i downloaded the sdk installer for MAC and installed it, the installation was at ease, even creating the projects and testing.
Appcelerator supports what we call "technology driven agile development" and we call that process Interactive Use Cases.
Aroma Systems – Be Guided By Your Senses
It has been 3 months since i joined the team at Aroma, and i have to say i enjoyed every single day.
Since i have been always a chaser to my dreams, i found the environment there suitable for me, it gives you the time and the conditions that will make you learn, develop, apply and innovate.
During these 3 months i have finished many projects, i learned a lot, and applied a lot of what i have been learning before during my career.
The team there is amazing, i enjoy working with them, we brainstorm on crazy ideas that looks impossible and we do it
,
We always focus on the new and top technologies that helps us build secure and fast application with very attractive user interface, and since the team is experienced in them and certified from large companies like Adobe, IBM, and Beta Testers for the technology makers like Zend "The php company" we know how to use the tools well to get the best output ever.
We made a new page to demonstrate our work, u will find a video there and some shots behind the scenes, i am sure u will like it. the video is quiet large but it is worth it, be patient
The link to the page is http://systems.graphicaroma.com
Aroma Systems is a department of Aroma Design & Solutions
we are working now on some projects that will rock the market soon
wish me good luck
Zend Framework, Flex & PHP – Best Practice Cautions
Hey guys,
recently me and my flex developer colleague had a weird problem while exchanging data from zend framework to flex as web services using json.
well, 1st caution :
<?php echo "Json = $encoded_json_data"; ?>
don't ever use a closing tag " ?> " in your controllers or classes, as it will result in new line in the output json data, which will make flex not able to recognize it correctly.
2nd caution :
<?php echo "Json = $encoded_json_data"; ?>
when u echo output from php don't leave space between the variable and the equal "=" sign and also between the equal "=" sign and the value.
to be clear :
example 1 :
This won't work as flex will not recognize a value for the variable Json.
example 2 :
This will work because we removed the spaces.
hope u don't fall in this trap as we did.
& enjoy