Recently, Symfony went from Zend-like bloat and rigidity to extreme decoupling and modularity. With the new Developer Experience initiative, Symfony has done a Laravel-style 180° and dove right into making its components more end-user friendly, its docs more complete, and its AppBundles unbundled, simplifying entry and further development almost exponentially. Considering user friendliness, it’s a long way from “best pals friendly” but it’s definitely no longer hostile. One factor that contributes to this factor a lot is their continuous pushing out of new components that are incredibly useful outside of Symfony’s context. One such component is the new VarDumper.
You’re developing a feature. You either don’t feel like writing tests, or what you’re developing needs some variable testing in the middle of a function - something you can’t quite cover with a test. Inevitably, you resort to something like
die(var_dump($var));. Even if you’ve abstracted it into a shorthand method like
vddd($var), it’s still clumsy and unreadable, and tends to leave debugging snippets around your code, either as comments or, even worse, as code that can actually be triggered.
There’s little choice in the matter - sometimes we simply need our
vddds. And sure, if you’re an Xdebug user, you’re probably used to a slightly better looking output than the raw PHP prints. Still, few good solutions existed that beautified this output for us enough to make it worth installing a dev dependency. Until VarDumper.
Continue reading %No More var_dump – Introducing Symfony VarDumper!%
Virtualization for Developers
March 19, 2015 20:00 CDT
Composer the Right Way
March 19, 2015 20:00 CET
- I have the honor today of writing a guest blog post on Igor Wiedler's Blog about Compilers. If you don't know @igorwhiletrue, he's pretty much the craziest developer that I know. And crazy in that genious sort of way. He's been doing a series of blog posts about Stack Machines and building complex runtimes from simple components. Well, today I authored a guest post on compiling code to run on said runtime. The compiler only took about 100 lines of code!!!
If you have played with Elasticsearch, you already know that analyzing and tokenization are the most important steps while indexing content, and without them your pertinency is going to be bad, your users unhappy and your results poorly sorted.
Even with English content you can lose pertinence with a bad stemming, miss some documents when not performing proper elision and so on. And that’s worse if you are indexing another language; the default analyzers are not all-purpose.
When dealing with Chinese documents, everything is even more complex, even by considering only Mandarin which is the official language in China and the most spoken worldwide. Let’s dig into Chinese content tokenization and expose the best ways of doing it with Elasticsearch.
What is so hard about Chinese search?
Chinese characters are logograms, they represents a word or a morpheme (the smallest meaningful unit of language). Put together, their meaning can change and represent a whole new word. Another difficulty is that there is no space between words or sentences, making it very hard for a computer to know where a word starts or ends.
There are tens of thousands of Chinese characters, even if in practice, written Chinese requires a knowledge of between three and four thousand. Let’s see an example: the word “volcano” (火山) is in fact the combination of:
- 火: fire
- 山: mountainsky
Our tokenizer must be clever enough to avoid separating those two logograms, because the meaning is changed when they are not together.
Continue reading %Efficient Chinese Search with Elasticsearch%
In this article I’m going to walk you through Medoo, a lightweight database abstraction library for PHP. Its main features include:
- Support for multiple databases - it supports MySQL, MariaDB, Sybase, MS SQL, PostgreSQL, and Oracle.
- Secure - prevents SQL injection, it uses PDO.
- Easy to use - its API is very intuitive.
While Medoo is nothing revolutionary, and the fact that it sports a very small filesize matters little to few, it’s still an interesting project that went from being outright dismissed to vaguely accepted, as evident in these threads. It’s on its way up, and that’s our reason for taking a look at it.
Even though the website recommends installing it by downloading a file and including it in your project, you should use Composer to do so.
Continue reading %Getting Started with Medoo – Examples of Use%