Bulgaria PHP Conference – Day 2 Recap

Today was the last day of the Bulgaria PHP Conference and after my Day 1 review, here’s my recap post from Day 2.

First off, I’d like to thank the organizers for the splendid event – great organization, incredible speakers list, solid WiFi, several areas for hanging out and a great atmosphere – looking forward to the 2016 version!

Drupal 8: The Crash Course

Larry Garfield gave a great talk explaining the transition from their handcrafted code built until Drupal 7 to their current code base in Drupal 8 based on a lot of open source libraries and tools. His Drupal 8: The Crash Course session explained the main concepts behind Symfony – one of the most heavily integrated suites with numerous components from version 2 of the framework now living in Drupal’s Core as well.

Drupal 8 is hardly recognizable if you’re used to the D6 or D7 architecture and syntax as compared to what lives in D8 now. Various components and core modules are removed in favor of the renewed system, including the PHPTemplate as announced by Dries today:

Another important announcement from the Drupal camp (pun intended) is bumping up the minimum PHP version – 5.5.9 or higher. Their new architecture allows for offloading configuration outside of the database to yml files or other sources, and defining data sources for different components. Additionally, Drupal can also run on PostgreSQL, MSSQL, Oracle and even with MongoDB!

Larry’s talk was essentially a complete tutorial, and includes a step-by-step guide for building a simple module with forms, database options and a simple frontend layer for displaying a multilingual template in the public area of a Drupal site. Plugins are available now for extensibility by defining and interface and a manager class in order to hook it to the core.

Some of the latest guidelines for D8 include:

  • Building smaller classes and smaller methods
  • Defining thin controllers
  • Moving logic to services
  • Avoiding direct database calls (now possible)
  • Make components unit-testable

Your Code are My Test! (Testing Legacy Code)

Michelangelo van Dam is one of the most influential figures in the PHP community, with tons of background in PHP (and Zend Framework), extensive knowledge in various areas and experience with other programming languages as well. Beyond his endless involvement with Open Source software, he’s the co-founder of PHPBenelux, the PHP user group in Belgium, Netherlands and Luxembourg.

Michelangelo touched on the painful problems when Testing Legacy Code and the standard excuses with no time or budget for tests:

He introduced the Pizza principle – the dough is the code, the topping are the unit tests, and the box is the documentation. After all, what help is a rough dough without topping and a box?

The main benefits of testing outlined by van Dam are:

  • Direct feedback when a test fails
  • Ongoing and growing base of tests adding up
  • Protection when refactoring existing code
  • Ability to debug easily having tests in place
  • High confidence and less uncertainty

There were numerous use cases discussed with systems failing due to the lack of unit tests, or saved after a unit test confirms that the problem is in a 3rd party service (a payment gateway).

Another real case scenario covered building unit tests for a random GitHub project – EPESI in this case, with a poorly coded architecture. Following a step by step approach, Michelangelo built a small group of tests covering different use cases in a bloated method and finding loopholes in the code as well in the form of a non-executable code. He reminded the group that certain scenarios could be tackled through reflection, such as private constructors or other fields and methods not exposed to the public.

One of the smart takeaways for me from the talk was the suggestion of adding a logger to a bloated method and logging specific variables, then tapping into the logger and asserting the logged entries. This is fairly bulletproof regression-wise and adds a separate layer for both logging and testability.

Mentoring: Change the World One Hour at a Time

I have discussed mentoring with Beth Tucker Long on Friday which was the reason I attended the talk today. Beth explained the general idea behind mentorships and the benefits for both mentees, and mentors.

Beth is a PHP developer and consultant and a User group leader, actively engaged with mentoring and apprenticeship. She explained the process from defining a problem, outlining the required steps, looking for a mentor, building the relationship, establishing some goals and targets, and ending the mentorship relationship (one way or the other). It is important to establish specific and measurable goals, clarify the type of mentorship (in terms of pace and communication style) and following up on the assignments in question.

Setting the expectations upfront is paramount for both parties, and this is the basis of a mentorship relationship. Someone from the audience touched on the friendship (or acquaintance) contact for mentors, and a quick discussion touched on the challenges of keeping the mentor hours from hanging out, as well as keeping both types of relationship separately instead of ruining them altogether in case of a problem.

PHP mentors are offering their services at phpmentoring.org so if you are a mentor or someone looking for one, go ahead and sign up there.

Shifting gears with Gearman

I wasn’t acquainted with Gearman which is why I attended the talk given by Srdjan Vranac.

Quoting Gearman’s website:

Gearman provides a generic application framework to farm out work to other machines or processes that are better suited to do the work. It allows you to do work in parallel, to load balance processing, and to call functions between languages. It can be used in a variety of applications, from high-availability web sites to the transport of database replication events.

Srdjan shared his experience with a project where he was assigned to migrate 30,000,000 products within 12 hours which would have required 695 migrations per second with a single instance. Using 600 nodes was a feasible way to migrate 1.1 products per second which is an easily achievable target.

Gearman is available in the package repositories of Debian/Ubuntu and RHEL/Fedora which makes it easier to set up. He elaborated on the challenges with running a large number of processes and dealing with memory and process management, and shared that the official manual is well documented and fairly useful. Srdjan reminded about possible failure vectors (network, database, I/O operations etc) and different possible concurrency issues, the paradigm behind the messaging queue and various ways to monitor as much as possible in order to prevent system failures (and everyone’s favorite segmentation fault errors).

During the Q&A Samantha and Michelangelo discussed some project specifics and raised some valid questions, including the fact that Gearman hasn’t been updated for over a year. RabbitMQ is probably a better alternative in that case.

Automation with Gulp and Bower

Michelle Sanver presented about Automating and optimizing the frontend workflow using Bower and Gulp. She is a backend developer who has been exposed to frontend-related projects which led her play with frontend dependency controls and automating repetitive manual tasks throughout Gulp.

Sanver introduced the audience to both tools and provided various examples for the entire workflow – installing them locally (and globally), introducing and pulling some dependencies and automating different operations – such as minification and combining of styles and scripts and compiling Sass files to CSS.

Down the Rabbit Hole

Cal Evans is one of the most visible and influential (as in “influencer”) people in the PHP community. Cal has been actively involved with the PHP and MySQL for 13 years now, and has been involved with numerous multi-million web applications built on top of PHP. His motivational and development talks have inspired a whole generation of developers and led to his active participation and engagement with other communities and reputable positions, up to his current title as a Technical Manager, Training and Certification at Zend Technologies.

It’s incredibly hard to describe a motivational talk, so it will suffice to say that the talk ended up with standing ovation. Cal guided us through his first days with technology and his first local meetup back in the days, his first role model in his family and a series of role models in the PHP community, his involvement with other languages, platforms, experience working with teams and recognizing the excitement of his team members attending conferences. He shared several personal stories attending different conferences and building a network of friendly professionals in a warm and welcoming community.

Cal Evans stressed on the fact that there are 5,000,000 PHP developers which help one another and support the community as a whole. I’m really grateful for the fact that he explicitly mentioned WordPress as one of the strong communities within the PHP world, given it’s bad rap amongst the broad PHP ecosystem.

As someone who has attended over a hundred conferences over the years – some business or marketing, some specialized in other industries, as well as technical conferences for Java, .NET, JavaScript, Open Source, Drupal and, of course, WordPress communities, my first PHP-oriented conference was truly inspirational. It was an honor to meet some of the titans of the PHP community in person, interact with the PHP community attending the event, discussing different tools, libraries, paradigms and solutions with other experienced professionals.

Leave a Reply

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