12

Hello, UMumble! Once, I was faced with a choice in the process of developing an authentication system for my project. Namely, what is the best way to store user passwords in the database? Many options came into my head. The most obvious were:

1. Storing the passwords as a plain text in a database.
2. Using regular hashes, such as crc32, md5, and sha1.
3. Using crypt() function.
4. Using the statical salt as type of structure md5(md5($ pass)).
5. Using the unique salt for each user.

The first and second options I had to eliminate for several reasons right away.
Pirat 4 may 2012, 20:45

imageIt was nice to find the website of this framework quite randomly in the second half of the business hours. New frameworks are rare, and even more rarely you come across mechanisms that are liked at first sight. Therefore, I would like to share my discovery with you.

First, I liked its name Nette right away. It's almost like a Latte. Only Nette as it turned out later is the Latte that has its own built-in template engine. Oh.

Second, at first view it created an impression of something new and advanced (they are almost as thoughts of the PHP team, pluging in the genius language the traits, and forgetting the boring Unicode):
  • HTML5
  • PHP 5.3
  • Built-in HTML template macros
  • Context-Aware Escaping technology
  • Configurations in the curious NEON format, on basis of which is generated PHP code
  • Own implementation of the base class for objects Nette \ Object
  • Events and subscription
  • Callbacks
  • New streaming protocol safe :/ / for an atomic access to the file system
ZimerMan 10 march 2012, 14:48

Here is a memo for novice exorcist:)

Before I begin, I know what are phpDaemon and System_Daemon. I read some articles about this subject.

So, let's assume that you've already decided that you need the daemon. What should daemon be able to do?

• It should run from the console and unbind from it.
• It should write all information to the logs, nothing output to the console.
• It should be able to create the child processes and monitor them.
• It should perform an assigned task.
• It should correctly complete a job.
Tags: daemon, Php
ZimerMan 20 february 2012, 16:34

imageThere is a widespread view that the ordinary PHP developer does not need to control memory management, but "controlling" and "knowing" are slightly different concepts. I will try to throw light upon some aspects of memory management when working with variables and arrays, and some interesting pitfalls of the internal optimization of PHP. As you can see, the optimization is good, but if you do not know exactly how it is optimized, you might meet the pitfalls, which can make you pretty nervous.

Overview


Learning the basics

In PHP a variable consists of two parts: "name" that is stored in hash_table, symbol_table and "value" that is stored in zval container.
This method allows creating multiple variables that are referring to one value, which in some cases allows optimizing the memory usage. How it looks in practice will be written further.

The most common code elements without which it is difficult to imagine a functional script are the following things:
- Creation, assignment and removal of variables (numbers, strings, etc.).
- Creation of arrays and their bypass (as an example will be used the function foreach).
- Passing and return values for functions / methods.
BumBum 9 february 2012, 14:16

In the Web you can find a lot of solutions to emulate multithreading in php. Most often they are based on the forks, but there are variations about using curl, proc_open and etc.

I did not like the alternatives that I found, so I had to write my own solution.
Here is the following set of requirements:

• Use of the forks
• In-sync state with the interface in the absence of the necessary extensions
• Multiple use of child processes
• A full data exchange between processes. That is, running with the arguments and getting results at the end
• The event exchange between the child process-"thread" and the basic process at work
• Handling the thread pool with the multiple use, transferring arguments and getting results
• Error handling
• Timeouts for the work performance, waiting for work thread, initialization
• Maximum performance

The result is a CThread library.

Here is a link to the sources:
github.com/amal/CThread
xially 7 february 2012, 13:10

After I have read some article about the handling of critical errors in PHP, I noticed that the error codes were customized specially for the bitwise operations in PHP, however, in the article’s examples and the comments are used regular operators for comparison in order to check the error codes.

For example, there were such variations:

if ($error['type'] == E_ERROR || $error['type'] == E_PARSE || $error['type'] == E_COMPILE_ERROR){…}
or

if(in_array($error['type'], array(E_ERROR, E_PARSE, E_COMPILE_ERROR)) {…}
Thereby, I decided to write a short article about the bitwise operations with examples of their use.
BumBum 2 february 2012, 21:20

The PHP blog touts more often the examples of bad code and anti-patterns. Well, someone else is criticizing the Hindus for the code ...
The code quality is something that should not be ignored or put aside for later. Such a delay is technical debt or code debt that will backfire for sure. You have to spend more time creating quality code and application architecture.

It is highly recommend to read Uncle Bob's principles of SOLID: butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod.
This text can greatly improve your ability to build scalable systems, particularly the principle of SRP.
xially 10 january 2012, 17:13

Smarty is one of the oldest template engines for the PHP development language. If you are programming in PHP, likely you have worked with it. A third version of this template was released in 2010. Smarty 3 was written from scratch with the active use of PHP5. At the same time Smarty got an updated syntax and modern features including inheritance, sandbox (computer security) and etc.
Twig is a modern template engine from developers of the Symfony. The authors have positioned it as the fast and functional template. It looks like Smarty 3 a lot in terms of features. Twig features a slightly different syntax, as well as the stated performance. Let us verify it!

Testing


We purposely is going to use quite complex templates during testing that the processing time would be noticeable. Actually, we will evaluate this time, so we will prepare the relevant scripts.

Code for Smarty turned out very simple:

$data = json_decode(file_get_contents('data.json'), true);
require('smarty/Smarty.class.php');
$smarty = new Smarty();
$smarty->compile_check = false;
$start = microtime(true);
$smarty->assign($data);
$smarty->fetch('demo.tpl');
echo microtime(true)-$start;
Tags: Php, smarty, twig
xially 30 november 2011, 12:40

The full list of changes and enhancements was released for NetBeans 7.1 beta.
We will focus on the most important changes that are related to PHP and the web development.

Support CCS3

There are supported and highlighted a new syntax, new elements and the pseudo-classes ...

image
xially 8 october 2011, 16:41