PHP Interview With Manuel Lemos Founder Of PHPClasses.org – Focus On The Problems Rather Than The Means To Solve Them

About This Interview

This is the #31st set of PHP Interview to help aspiring PHP developers and PHP fans alike to get inspired by listening from those PHPeople who are already highly involved into the PHP Ocean and *being there* taming the waves and surfing better than ever to make themselves an Awesome PHP Expert both in their own eyes (for self-accomplishment) and for the PHP Community.

On the other side, this is an opportunity for new PHPers to get to know their “PHP Elders. I hope you will derive as much fun to read my interviews as I’m having by interviewing those awesome PHP people.

A Small Intro..

Manuel Lemos Founder Of phpclasses.org

In this edition I talked with Manuel Lemos who is the founder of the famous and huge PHPClasses.org. @ManuelLemos has been rambling a lot about PHP, doing all sorts of stuffs on phpclasses back since 1999 – podcasts, interviews, sharing scripts, writing scripts, blogging, shouting and I even doubt he drinks-eats-sleeps there too (just to say how much he is hooked in there).

And Now The Interview…

>> Please tell us a bit about yourself

I am graduated in Electronics and Telecommunications by the University of Aveiro, city where I was born in Portugal, but I always have loved and worked with software development since I was 13 when I started experimenting with programming with 8 bit computers.

I moved permanently to Brazil in 1998 where I live and work until these days.

>> How you started with PHP

I started with PHP in 1997 in the PHP 2 beta days. It was still totally procedural but it was useful enough to develop any sites.

Then I was working on a research project for Ericsson in my university and I could use PHP and mini-SQL to provide a Web based user interface to control a wireless local loop communications system.

Previously I have developed a lot in C, so PHP was a dream come true of having a sort of interpreted C language that would let me test my developments without having to wait to recompile the whole project code.

>> Your LAMP stack comprises..

I use a mix Apache for PHP and a multi-threading Web server for static content. Linux and MySQL are standard in all my developments, although I use a database abstraction package named Metabase that allows me to move to any other OS or SQL database if I need to.

>> The relationship between You and The PHP Community comprises..

I work full time exclusively on my own PHP sites since 2001 by my own choice. I feel that I am privileged to work full time on something that I have chosen for my own company.

>> How do you find PHP now as compared to when you first started

PHP evolved hugely since 1997 but I think the main spirit of addressing the most important Web development needs prevails since then.

>> Based on your experience, what are the good and bad parts of PHP

I think the most important good thing about PHP is the pragmatic spirit of the people that developed the language features, so the language addresses exactly real world needs of Web applications.

On the bad side, there is some inconsistency in terms of function naming and parameter order that forces you to keep going back to the PHP manual to be reminded of the exact usage. But you get used to it, so it really does not upset me much.

>> What would be the Top advice to a PHP beginner

I think a developer should focus on the problems rather than the means to solve them.

I notice that specially developers that have came out of college recently are a bit obsessed to use all the design patterns they learned in school.

Showing that you know lots of design patterns is a fine exercise to demonstrate your knowledge to your teachers, but in the real world your teacher is no longer there to give you a grade for the code you write.

Your software should be self-explanatory even without comments. It should be easy to read and understand what it does. If you try to push more design patterns than you need, you will be solving the real world problems in an inadequate way.

Unnecessary complexity will cost more to develop and you will be doing a disservice to the companies that pay for your work, as you will be taking more time to develop and maintain the software.

>> To someone who wants to become a better PHP developer..

Practice a lot. Only by practicing more you can get more experience in addressing real world needs of software projects.

If your day job is to work for somebody else, try creating your own sites for an useful purpose. That will help you getting a better feeling of how much certain decisions will cost in terms of time and money to develop and deploy.

Even if you continue to work for somebody else, the experience that you will earn working in your own projects will help you becoming more efficient in providing value working for others.

>> The best PHP book you’ve read

The PHP online manual, definitively. There are plenty of good PHP books out there, but the PHP manual is the greatest written source of PHP knowledge, especially considering the additional comments that community contributed to the manual pages.

>> A PHP blog or Resource you highly recommend

Chris Cornutt The Hero Behind PHPdeveloper.org

PHPDeveloper.org. Chris Cornutt does an awesome job gathering great summaries of the most important things that happen in the PHP world.

I had the privilege to meet him in person in 2008 and he told then that he had over 150 RSS feeds to follow blogs and other PHP resources. He reads all of them and picks the most important to put in PHPDeveloper.org.

This is definitely an great labor of love that we PHP developers benefit for free without having to spend countless hours reading all the blogs he reads. Kudos to Chris for his dedication.

>> The IDE that you use

I use a simple text editor on Linux named Kate. It is part of the KDE distribution.

>> How do you debug your PHP code?

error_log() and print_r() is what I often use in my development environment to inspect values and output them in a way that does not interfere with the execution of the code. Then I monitor the PHP error log file to see the values I want to inspect.

I have tried IDEs with debuggers but usually they are such a pain to setup, consume so much memory and time to get started, that I feel discouraged to even start using them.

In the production environment, since nobody can avoid shipping code totally bug free, I also monitor the PHP error log file to be aware of any warnings that PHP throws.

I have been using a simple class named Log Watcher that regularly checks if the PHP error log file. If there are any new error log lines, it sends them to me by e-mail so I can act promptly and fix any issues as soon as possible. I lost count of how many times this simple class saved me from greater troubles.

>> A PHP framework you use and would recommend

Personally I do not use a specific framework written by somebody else. What I use is my own collection of classes for various purposes depending on the needs. The classes do not have great dependencies on each other, so I rarely use many classes at once that would justify using a typical full stack framework bundle.

For separation of concerns, often known as MVC, I use a methodology that I developed many years ago named use case mapping. I divide projects in sub-systems, each sub-system is divided in use cases (also known as user stories), and each use case is mapped to a class. All use case classes have the same interface of functions and variables, so development becomes very productive.

A specific function of a use case class takes care of processing (also known as controllers). Another function takes care of the output (also known as views). Separation of concerns is good but it does not require that you separate things in different classes. As a matter of fact, it is convenient that processing and output are bundled in the same class, as they need to pass values to each other, which I do via private class variables.

The processing function calls service classes (also known as models). These service classes may be proxies that connect to application server components running eventually in separate machines, for instance based on Gearman.

In the past I wrote an article about this methodology. The article is a bit outdated because it does not cover service classes.

>> A unit test framework you recommend using?

I do not use a specific framework for testing. PHP is so powerful that it already provides the basic building blocks to do it with minimal amount of code. You can just use output buffering to capture the output of a script you want to test. Then you compare the captured output with a file that has the expected output. If the comparison fails, you found a broken test.

Other than that, I also do not defend the whole Test Driven Design approach that some developers preach so enthusiastically.

It is one of those things that are only good in the ideal world. In the real world TDD is too expensive to implement in all the code you write. Usually it takes you much more time to write tests than to write the actual code. Basically I agree with Joel Spolsky point of view on this. [@spolsky]

That does not mean that I am saying that you should never write tests. It is quite the contrary. I am saying that you should write tests for very specific things that cannot fail, like things that would be too expensive to recover from the failures if they happen in production. For instance:

  • Things that deal with people’s lives
  • Things that deal with money
  • Things that could cause irreversible damages if you lose control, like for instance a robot sent to Mars
  • Code that deals with complex conditions and you are not confident that your code is handling right all the cases.

>> A CMS that you think is worthwhile

WordPress. I do not use it myself but its plug-in ecosystem is awesome.

I had the pleasure to meet Matt Mullenweg, the creator of WordPress, in person here in Brazil in an free software event. He is a very simple person always with good humor, but the success of WordPress made him a rock star.

WordPress succeed because it can be all things for anybody thanks to the plug-in system that Matt devised to extend WordPress.

>> An E-Commerce cms you recommend

I have no experience on third-party e-commerce systems. All e-commerce development I did was 100% my own custom development.

>> Do you recommend using database layers and ORM? If yes, what database framework you would recommend?

Yes, definitively. For database abstraction I use Metabase which is a package that I started in 1999. It provides truly database independent applications in PHP. It takes care about both the database access and the database schema management. It was the first PHP database abstraction layer to have this focus.

You just define a database schema file and it takes care of applying the necessary changes without making you remember the exact syntax of the SQL queries to create, drop, or alter your database tables.

It implements a much smoother and fail safe approach than having to do it with what other people call migrations. There is no up or down procedure.

There is an old and a new schema file. Metabase schema manager evaluates the changes you want to do and tells you if they are not allowed before executing them. This is an extraordinary time and pain killer when you want to perform safe application upgrades (or downgrades).

As for ORM I have been developing an ORM system since 2002 named Metastorage (do not confuse with Metabase). It is not a run time ORM library, but rather a 100% code generation tool. It generates factory classes and mapper classes that store and retrieve database table records as objects.

You just define what your objects are in a file in terms of variables, collections and relationships, as well the functions you need your ORM classes to perform at application run-time like creating, retrieving, updating and deleting objects. You just ask what you need, so the resulting code is very efficient, very close to what I would write by hand.

Metastorage generates all the classes for you. You do not need to touch the generated code. If you change your objects’ definition, just tell Metastorage to generate the code again. It takes just few seconds.

It supports its own object query language that is very similar in power to SQL. It compiles the OQL clauses into logic code embedded in the generated ORM classes, so you do not need to compose conditions dynamically at run time. Your database schema will not change at run time, so you do not need to compose conditions dynamically.

Metastorage approach lets you be more productive and generate more reliable code as any OQL errors will be anticipated at compile time.

Furthermore Metastorage supports report queries. This is more appropriate to retrieve data for read only purposes. Instead of retrieving data into objects, it returns arrays. This is much more memory efficient than using objects, especially when you need to deal with large amounts of records.

Imagine when you need to send a newsletter to one million users. What happens if you retrieve 1 million objects into memory when you just need a few values of each of those objects (say the user name and email)? It will exceed PHP memory limits. Arrays with just the necessary information are far more adequate.

>> One PHP library/Project you really appreciate

I already mentioned WordPress. Despite I do not use it, I reckon that the success and prevalence of PHP is tied to WordPress and vice-versa.

>> One function that you like (or which you tend to use frequently)

I am not really attached to the code I use. So I would rather mention a couple of functions named strspn and strcspn.  They are not very well known despite they exist since the early PHP versions. These are functions that come from C. They are good for parsing text without creating any sub-strings. So they are useful to create parsers that are both efficient in terms of performance and memory usage.

>> One PHP person that you admire and what strikes you about him/her

It is hard to just mention one, but I would say Rasmus Lerdorf. The reason is not just because he is the creator of PHP, but he always pushed PHP to be a pragmatic solution for Web problems.

He is not really a consensual person but his pragmatic sense has been vital to the success of PHP as a solution focused on the needs of real world Web applications.

>> One PHP Community that you recommend

I don’t know all the PHP communities worldwide but from those that I know I would say PHP Brasil Comunidades. This is a meta-user group. It is a group of leaders of local user groups in Brazil. It was created by Pablo Sánchez many years ago to foster the cooperation between user groups in addressing common problems that the groups have.

>> Are you part of any PHP User group?

I have been away from the local user group scene since 2008 because getting involved was taking me too much time and I was not giving the necessary attention to my company’s business.

Anyway, in 2002 I helped creating a local user group in the city that I live in Brazil. In the beginning it went OK but soon I realized that only a few members were willing to put time to organize the group activities.

I ended up stopping to participate. I figured that user groups will only survive if there is a critical mass of members that rotate and divide the organization tasks.

That was when I decided to create a user group directory in the PHP Classes site. The idea was to expose the existing user groups to the new users that come to the site. When a user log in the site, he tells the country he lives in and the site shows a map of user groups of that country. That helped attracting many thousands of users to the users groups that got listed in the site.

Unfortunately many user groups end up dying soon or later. So, I implemented a verification system that checks if the user groups pages still exist. If there is a problem, the user groups leaders can tell if their groups died or it is a temporary problem that they can fix.

This helped solving a problem that many user groups directories have, which to list dead user groups. If the groups are not checked regularly, user groups directories turn into cemeteries. That would only make the users interested in the groups waste time checking manually.

>> A PHP Usergroup that you appreciate and would highly recommend

It is hard to recommend a specific group but in the PHPClasses site user groups directory there is a ranking based on the number of the active users that claimed to be of each user group. These are not necessarily the most active user groups in the world, but from those listed in the site these seem to be very active.

>> Which was the worst programming mistake you did?

I would say one that got me a great embarrassment because it upset many users. It happened when I was testing a new feature in my development environment that would send e-mail notices to many users.

Since it was a test, nobody should have been mailed. Unfortunately I forgot that postfix server was running on my development machine. So thousands of messages were sent to the users inadvertently.

That made me think more about how can I protect myself better from my own mistakes by limiting the possible damages. I have even written an article about defensive programming that addresses this matter.

Manuel & Brazilian PHP

>> Would you have an approximate figure about the number of people involved with PHP in Brazil?

In PHPClasses 5% are from Brazil. If we assume the whole PHP community has something like 6 million developers, that probably leads to 300.000 in Brazil, but I am not sure if the assumption is accurate.

>> And approximately how many php-usergroups there?

Here shows 38 user groups, but 21 are listed as inactive. They are sorted by the ones that have more members.

>> Reading through the net, it seems like Brasil do have an impressive activity going on both in the PHP and IT world
>>>> i) what is the secret behind?

Brazil is very social. People enjoy get together with other people. So if you organize activities that gather people, Brazilians tend to adhere easily.

>>>> ii) One area which you believe Brazil excel brilliantly as compared to other countries

This is hard to tell because Brazil is a country of high contrasts. I mean the good is very good and the bad is very bad. In Brazil there are a few individuals and companies that are really good on what they do, but that is the same like in very country.

>>>> iii) Areas where you think Brazil needs to improve as compared to other countries

Brazil lacks of serious professional PHP events. I am not talking about conferences that people go there present something they proposed. To those events they can go just for the fun of meeting with the community. I am talking about conferences on which speakers can present professional talks and be paid as professional speakers.

There are events like this in other countries but Brazil lacks them because companies behind the existing events are only willing to organize conferences on which they do not have to invest on the speakers.

Manuel & PHP Conferences

>> The best conference you attended would be..

I attended the International PHP Conference in Germany. That is a professional event very well organized. It is not cheap but if you are serious with your PHP career the money you pay is well worth the investment.

>> Can you please share the good, and may be not so good moments, of being part of all the conferences you attended

Conferences are always good opportunities to meet people in person that you only know from the Internet.

On the down side, there seems to be a small group of PHP developers that are a bit spoiled. They think of themselves as superior to other developers because they got additional attention. They forget that attention is a temporary effect that a conference may get you. Treating others as inferior people only makes you lose opportunities.

Unfortunately some conferences keep approving some people like that to give talks because they confuse temporary fame with real reputation.

>> What are the main aspects of conferences that can really help a PHP guy to get better in his progression

Proposing yourself to give interesting talks can be a great opportunity to earn some reputation, especially if you give talks about things that are appreciated by others.

I just would recommend that you avoid focusing too much on yourself. I have seen talks that are totally useless because all the speaker said was to promote himself.

Unfortunately this happens a lot in conferences on which the speakers are not paid to speak. So they get their payback by focusing on promoting themselves and their own stuff.

Closing out With Manuel..

>> Things that you’ve learned by being part of The PHP Community

The main thing is that you can’t please everybody. Each person has different needs. Even if you try to address the needs of the PHP community in general, there is always people that does not agree with the approach and can engage in criticism campaigns.

Criticism is OK. If you are never subject to criticism, you are not having great impact in the world.

Sometimes it is necessary to clarify misunderstandings. Other times the criticism is valid and useful to understand problems that I have not perceived before. It helps me to focus on improving important things. Many of the things I did were result of improving upon criticisms.

>> Are you happy with the way PHP is heading?

PHP is fine but it could be better if the official PHP distribution had a dynamic JIT compiler engine like the one now provided by Facebook HipHop.

Dynamic JIT compilation allows PHP code to be compiled into native machine code progressively during its execution. This means that code could run increasingly faster over time after it is deployed.

Zend engine approach is fine but it is no longer modern. Even now with the inclusion of Zend Optimizer+ cache extension in the version 5.5, PHP standard installation will be a bit better but that is not a modern approach to execute PHP code as fast as it could with dynamic JIT compilation.

Another thing is the lack of thread safety certification for PHP extensions. Zend engine is thread safe but some PHP extensions are not safe enough to run PHP in threads, rather than processes.

Again Facebook HipHop solved that problem. It generates multi-threading Web servers for PHP applications. Threads running on the same machine share the same memory pool, so PHP applications can serve many simultaneous users using less memory. This reduces the cost of scalability, I mean the number of machines needed to serve the same number of simultaneous users. We discussed about this here:

  1. http://www.phpclasses.org/blog/post/168-Can-NET-make-PHP-run-faster-than-the-official-PHP-implementation.html
  2. http://www.phpclasses.org/blog/post/170-The-Debate-of-Making-PHP-Faster-using-a-JIT-Compiler–Lately-in-PHP-podcast-episode-19.html
  3. http://www.phpclasses.org/blog/post/196-Will-PHP-6-feature-a-JIT-compiler-Lately-in-PHP-podcast-episode-30.html

Lets see if PHP 6 evolves and adopts Facebook developments for the benefit of a greater community.

Another aspect is asynchronous programming. Node.js provides support for asynchronous programming in JavaScript. This means that it can execute several I/O tasks in parallel and make applications more efficient.

For instance you can tell the database server to execute a query. While the results are not returned from the server you can execute some other task in parallel, like preparing the templates to present the database results.

PHP has limited support for asynchronous programming. You can connect with servers via sockets asynchronously but it is a bit odd the efforts of programming all to do that. An approach like Node.js would be more adequate, except that I would provide both an asynchronous and a synchronous way to access databases, files and remote network servers.

That is a topic that I also discussed here: http://www.phpclasses.org/blog/post/133-Accelerate-scripts-running-multiple-tasks-in-parallel-using-asynchronous-programming-Unusual-Site-Speedup-Techniques-Part-3.html.

>> How do you time manage all the stuffs that you do, coupled with your personal life?

I work 100% at home, so I have a flexible schedule to manage both domestic and professional issues.

>> The day you realised You’ve made it to the A-List PHP arena?

I was not aware of an A-list if there is such thing. I hope that is a good thing! 🙂

>> Why you are successful and why others are not?

Being successful as seen through the eyes of others is not a thing that I have as a main personal goal. I try to address my needs. It happens those are also the needs of others.

I get very anxious because I have plenty of cool things to do on my to do list and not enough time to do them as fast as I hoped. I have to be patient and determined to pursue those goals until they are achieved.

Still I cannot complain. I am fortunate enough to work by my own choice on something that I created. Not everybody aims for that. For those that have the same desire but did not get there yet, I just recommend to focus and keep trying because soon or later you will succeed if you are persistent.

 

Now Do Your Part!

1) LIKE 7PHP dot COM on FaceBook – if you appreciate what I do

2) Help diffuse this interview to the PHP ecosystem – Share, tweet and spread the word to your audience ==> That would be a FREE way to thank me 😉

3) Make a comment below using the comment form – I’m sure you can at least say 1 word about this interview

{I’m thankful to your response(s)!}




Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.