It is announced that PHP 7.0 is scheduled for release at later of 2015. Some of the key improvements are listed as below,
- Improved performance: PHP 7 is up to twice as fast as PHP 5.6
- Consistent 64-bit support
- Many fatal errors are now Exceptions
- Removal of old and unsupported SAPIs and extensions
- The null coalescing operator (??)
- Combined comparison Operator (<=>)
- Return Type Declarations
- Scalar Type Declarations
- Anonymous Classes
As for the exceptions, structured as below,
├── \Exception (implements \Throwable)
│ ├── \LogicException (extends \Exception)
│ │ ├── \BadFunctionCallException (extends \LogicException)
│ │ │ └── \BadMethodCallException (extends \BadFunctionCallException)
│ │ ├── \DomainException (extends \LogicException)
│ │ ├── \InvalidArgumentException (extends \LogicException)
│ │ ├── \LengthException (extends \LogicException)
│ │ └── \OutOfRangeException (extends \LogicException)
│ └── \RuntimeException (extends \Exception)
│ ├── \OutOfBoundsException (extends \RuntimeException)
│ ├── \OverflowException (extends \RuntimeException)
│ ├── \RangeException (extends \RuntimeException)
│ ├── \UnderflowException (extends \RuntimeException)
│ └── \UnexpectedValueException (extends \RuntimeException)
└── \Error (implements \Throwable)
├── \AssertionError (extends \Error)
├── \ParseError (extends \Error)
└── \TypeError (extends \Error)
Xdebug is crucially important for PHP stack trace debugging.
Here is what I have done to get started.
- Install Xdebug in ubuntu,
sudo apt-get install php5-xdebug
- Modify php.ini to activate Xdebug
; file of /etc/php5/fpm/php.ini
- Restart the webserver
sudo service nginx restart
On a separate note, for an important feature, now we can call the function,
// stacktrace debug till the calling point
// stacktrace printing message till the calling point
xdebug_print_function_stack( 'Your own message' );
Thess functions will find out all the trace back for current calls.
First one will display every parameters within it. Extremely useful for debugging through large codebase.
Or follow the instruction on Xdebug. (Cited from Xdebug
Unpack the downloaded file with tar -xvzf xdebug-2.3.3.tgz
Run: cd xdebug-2.3.3
Run: phpize (See the FAQ if you don’t have phpize.
As part of its output it should show:
Zend Module Api No: 20121212
Zend Extension Api No: 220121212
If it does not, you are using the wrong phpize. Please follow this FAQ entry and skip the next step.
Run: cp modules/xdebug.so /usr/lib/php5/20121212
Update /etc/php5/fpm/php.ini and change the line
zend_extension = /usr/lib/php5/20121212/xdebug.so
Restart the webserver
PHP version difference is something that likely to be neglected for most “script writers”.
Especially when upgrading system, paying attention to version difference is extremely important when you looking after the code.
Here are some brief points that in my opinion should be remembered all the time.
- From PHP5.2 to PHP5.3
(Most php version starts from PHP5.3 now. If not, urgently upgrade!!)
- Since PHP5.3 has namespaces, this is critical important for modern PHP development. Needed for most of modern frameworks
- PHP5.3 support native closures
goto is enabled
- If version PHP >= 5.3.7, password_compat lib can be used for encrypting passwords by BCRYPT implementation. Ref Here
- From PHP5.3 to PHP5.4
(This is the major upgrade, several key points needs to be remembered)
- MAGIC QUOTES is removed. The evil is gone.
- Safe Mode is not supported, which used to check the ownership of script matches the owner of the file to be operated on.
- Closure support
- Support build-in Test only server such as
$ php -S localhost:8000 -t foo/
- From PHP5.4 to PHP5.5
- Windows XP support dropped
finally block added
- New password Hahsing API as mentioned earlier. (
- From PHP5.5 to PHP5.6
- Exponentiation Operator ** is added
json_decode will see non-lowercased variants of true, false and null as invalid.
DAO is access object, and is definitely categorized as C in MVC scheme.
Quote from wiki (since it quite explain itself):
an object that provides an abstract interface to some type of database or other persistence mechanism. By mapping application calls to the persistence layer, DAOs provide some specific data operations without exposing details of the database.
DAO is solely responsible to DAO clients. And DAO clients should not have knowledge of the database schema as well as each others’ functionality.
DAO provide the transparent layer for its clients to DB handling. In this sense, it is also required that an fully functioned DAO should cover all the aspects of an DB’s ever contained information which are intended for public access of course.
The question of why we need DAO instead of handler/object ?
The answer should be straightforward obvious from the above argument. However, to sum it up, it is quite critical that we have an handler which focus on nothing but covering all the information from DB.
To the contrary, Handlers/Objects are for building up apps only. They are designed and customized based on the apps’ needs, and is oriented by the apps’ functionality. They do not necessarily fulfill all the needs from DB.