Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Development on Free Software - php - Xavier Castaño García
This session <ul><li>This class will be only practice. We'll try to view this topics: </li></ul><ul><ul><li>Objects and In...
Objects and inheritance <ul><li>Exercise 1: We are going to develop a class which extends “userhandler.php” in order to ch...
Objects and inheritance <ul><li>Comments: </li></ul><ul><ul><li>You can see that in php 5 you can: </li></ul></ul><ul><ul>...
Configuration <ul><li>Exercise 3: We are going to add mysql configuration variables to file and the we are going to read f...
Development with templates <ul><li>Exercise 4: We are going to develop a form where we ask for user and password. </li></u...
Development with templates <ul><li>Comments: </li></ul><ul><ul><li>Smarty is a template engine, but there are more engines...
Session <ul><li>Exercise 5: We are going to know if user has been authenticated in the same navigation but without asking ...
Session <ul><li>Comments: </li></ul><ul><ul><li>Session allows to store persistent data between different requests. </li><...
Other useful trips... <ul><li>That allows you to add hooks. Methods to be called only using the name of the class and the ...
Interesting links <ul><li>PRADO:  http://www.xisc.com/ </li></ul><ul><ul><li>PRADO is a component-based and event-driven f...
Upcoming SlideShare
Loading in …5
×

Php session

1,651 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Php session

  1. 1. Development on Free Software - php - Xavier Castaño García
  2. 2. This session <ul><li>This class will be only practice. We'll try to view this topics: </li></ul><ul><ul><li>Objects and Inheritance </li></ul></ul><ul><ul><li>Development with templates </li></ul></ul><ul><ul><li>Configuration </li></ul></ul><ul><ul><li>Session </li></ul></ul><ul><ul><li>Other useful trips... </li></ul></ul>
  3. 3. Objects and inheritance <ul><li>Exercise 1: We are going to develop a class which extends “userhandler.php” in order to check if username and password matches with the parameters passed. </li></ul><ul><ul><li>Keywords: mysql (mysql_connect, mysql_query). </li></ul></ul><ul><li>Exercise 2: We are going to extract mysql functions from handler in order to avoid coupling between handler and mysql. </li></ul>
  4. 4. Objects and inheritance <ul><li>Comments: </li></ul><ul><ul><li>You can see that in php 5 you can: </li></ul></ul><ul><ul><ul><li>Autoload objects </li></ul></ul></ul><ul><ul><ul><li>Define visibility </li></ul></ul></ul><ul><ul><ul><li>Use the scope resolution operator (::) to access static, constants overridden members. </li></ul></ul></ul><ul><ul><ul><li>Define abstract classes, interfaces. </li></ul></ul></ul><ul><ul><ul><li>Overloading __set, __get, __isset, __unset and __call. </li></ul></ul></ul><ul><ul><ul><li>See: http://www.php.net/manual/en/language.oop5.php </li></ul></ul></ul>
  5. 5. Configuration <ul><li>Exercise 3: We are going to add mysql configuration variables to file and the we are going to read from it. </li></ul><ul><ul><li>Comments: We can do the exercise with a simple php file. But, you could: </li></ul></ul><ul><ul><ul><li>Use property files. </li></ul></ul></ul><ul><ul><ul><li>Use XML files. </li></ul></ul></ul>
  6. 6. Development with templates <ul><li>Exercise 4: We are going to develop a form where we ask for user and password. </li></ul><ul><ul><li>Keywords: Smarty </li></ul></ul>
  7. 7. Development with templates <ul><li>Comments: </li></ul><ul><ul><li>Smarty is a template engine, but there are more engines. </li></ul></ul><ul><ul><li>I think HTML shouldn't be mixed with php, with some exceptions. </li></ul></ul><ul><ul><li>Templates shouldn't have a lot of logic. </li></ul></ul><ul><ul><ul><li>Good practice: You use an “if” in order to get different colors for even and odd rows. </li></ul></ul></ul><ul><ul><ul><li>Bad practice: You decide to show a field depending on a value because your business login has this requirement. </li></ul></ul></ul>
  8. 8. Session <ul><li>Exercise 5: We are going to know if user has been authenticated in the same navigation but without asking again the user and password. </li></ul><ul><ul><li>Keywords: Session </li></ul></ul>
  9. 9. Session <ul><li>Comments: </li></ul><ul><ul><li>Session allows to store persistent data between different requests. </li></ul></ul><ul><ul><li>It isn't recommendable use the session to store too much data. </li></ul></ul><ul><ul><li>Session stores the data serialized, so you could have problems with two simultaneous request modifying it. </li></ul></ul>
  10. 10. Other useful trips... <ul><li>That allows you to add hooks. Methods to be called only using the name of the class and the name of the method itself. </li></ul><ul><li>Example: </li></ul><ul><ul><li>$className = “myclass”; </li></ul></ul><ul><ul><li>$object = new $className; </li></ul></ul><ul><ul><li>$object->method($params...); </li></ul></ul>
  11. 11. Interesting links <ul><li>PRADO: http://www.xisc.com/ </li></ul><ul><ul><li>PRADO is a component-based and event-driven framework for rapid Web programming in PHP 5. </li></ul></ul><ul><li>CakePhp: http://www.cakephp.org/ </li></ul><ul><ul><li>CakePHP is a rapid development framework for PHP that provides an extensible architecture for developing, maintaining, and deploying applications. </li></ul></ul><ul><li>Symfony: http://www.symfony-project.org/ </li></ul>

×