Enterprise
January 24, 2022
13 min read

Geeking Out Over PHP on Kongcast

Viktor Gamov

In this episode of Kongcast, I went all-in on PHP, Laravel and PHP developer tools with Freek Van der Herten, a backend developer at Spatie. Then, Freek demoed his new PHP debugging tool: Ray.

Check out the transcript and video from our conversation below, and be sure to subscribe to get email alerts for the latest new episodes.

I’m mostly on the Java side or JVM side of things. But today, we’re going to be talking about PHP. Freek promised me that he'd bring a fresh perspective. Java is kind of old school. Freek comes from this new and shiny world of PHP. Java is considered very close to COBOL and very enterprisey and almost dying out.

Freek: I would say that there is more credit that we can give to Java. I don’t think of it as a bad language per se. But yeah, my preferred language is PHP because I spent the most time in there, and it’s like you said, awesome features.

How Freek Started With PHP

Viktor: And before we jump to this one, can you talk a little bit to our listeners about how you ended up here? Was PHP always your thing, or were you doing something else before?

Freek: I’ve been in web development for a little bit over 10 years now. Before that, I was a COBOL programmer in a big financial institution.

I wound up in web development because a buddy of mine, which I was in a band with, started his own company. He thought, "Yeah, the internet is going to be very big. We need to do something with this. I’m going to create websites." And my buddy was good at the visual side of things but not so much the programming side of things, so he asked me, "Hey, don’t you want to join me?"

At the time, I was getting a little bit tired of COBOL, so I thought, “Hey, let’s give this web thing a spin.”

At the time, PHP was - and still is - a free language to use. Using it instead of the Microsoft alternatives that cost a little money made sense. I was not too wealthy. So PHP was a perfect choice for me.

Viktor: And how the tables have turned, right? Microsoft is always giving away all this stuff for free.

And I remember this period of time as well. I was in the middle in terms of where I should go. Should I go with the Microsoft stack or go in with some open source tech? Around 2008, people started doing a lot of PHP work, but I came from more like a traditional C++ world. A transition to something like a C# was more natural for me.

That’s why we have divided - not the two different camps or whatnot, like camps of or religions - but some people decide, "OK, so we’re going to start making money, and you people can make money for Microsoft. So we don’t want to do anything with this." So I totally get what you’re talking about in the world's situation.

Freek: Yeah, it seems like a long time ago, right? And, as you said, the tables have turned a little bit. Microsoft is another kind of company now.

What's Awesome About PHP?

And also, you touched upon this too. PHP has also evolved, so it’s no longer that little scripting language. Many features have been added these last few years, making it an enjoyable and powerful language to work with.

PHP has this image of being too open or too dynamic. And while I like the dynamic nature of PHP, you can adopt a very strict style as well, to which things can be typed in big ways. Clauses can be made final. For some people, it’s even surprising that you can define interfaces with PHP. I know that wasn’t true in the old versions of PHP. It’s come far. New features are coming in every year.

Viktor: With PHP and the evolution of these languages, everything started as a scripting language on top of an HTTP server. Or you can write some console scripts with this as well. But the majority of the work was around supporting web development and web developers.

Freek: Indeed.

Viktor: Does it still require an HTTP server, or does PHP already have batteries included?

Freek: PHP can be run in multiple different ways. It’s not only invoked via HTTP. You can just invoke it from your CLI without any server as well. And, of course, invoking it via HTTP is probably the most common way to do this. But with modern applications, you also need to schedule jobs, which are run via the CLI. And this can be done with PHP as well seamlessly.

There are a couple of very good components. For example, the Symfony process, or Laravel Zero, makes it easy to create console applications with PHP.

Freek's PHP Journey

Viktor: Let’s get back to the story you told us. So you started with your friend developing new websites. How did you progress from this with PHP?

Freek: That’s a great question because there is quite a journey there. I still remember creating my first PHP website, which I had created more than 10 years ago. And I did that in Notepad, so with almost no tooling at all. I used PHP in an old-school way where I just mixed PHP with HTML in one file. And that’s it.

Viktor: As we all did.

Freek: Yeah, indeed. Every PHP dinosaur that started 10 years ago or a little bit more than 10 years ago did it this way.

But of course, if you’re going to build bigger things and more complicated applications, that structure breaks down very easily.

So with the company that my buddy Will and I and another founder started, we created the first very smallish websites - just a couple of pages, nothing too dynamic. But of course, we are ambitious, and we want to do bigger things, and clients ask for bigger things, so they want us to create full-blown applications. And for that, you can’t do that on your own. You really need a framework to handle the routing requests and send responses.

These are things that other people can program very well. You shouldn’t do that yourself.

Viktor: A famous MVC model like arrays of the MVC model that you will try to like a code of different bits of business logic on the side, and the presentation of this logic will be run on the different side. The traditional object-oriented language will start growing bigger because of all these frameworks.

PHP Frameworks

If you look at C#, there was speed.net. If you look at Java, there were GSPs. Open source frameworks appear for building this stuff. So how is this situation in the PHP world? Was there a framework that united everyone and started doing cool stuff, similar to a model view controller pattern or whatnot?

Freek: Developers do not always agree on everything. There are multiple perspectives on this. In the PHP world, we always have multiple frameworks going on. Some became a little bit bigger than others.

In the beginning days, the biggest ones were probably Zend and Symfony. These are still around today. Zend has been renamed something else, but I think it’s still more or less the same.

But one of the more modern ones that came to be about 10 years ago but only rose to popularity five or six years ago is Laravel, a batteries-included framework. This is also a very healthy situation to have multiple frameworks going on. These days it’s mostly Symfony and Laravel that are, I would say, the top dogs. And I think both of these frameworks steal features from each other in their own way—Symfony tries to be very strict and follow the rules, while Laravel tends to be a little looser and a bit more developer-focused. And there are things to be said for both approaches, I think.

Viktor: Is it fair to say that right now, Laraval is the de facto standard for web development in PHP or general development? What’s the position, and how does this framework position itself? And what’s your involvement there? How do you help? Since you mentioned you're a big fan of Laraval’s, you probably like the looseness of it. And this is where you can, you know, talk a bit about the work you’re doing in this community?

Freek: I don’t think that Laravel is the de facto standard. It is just a framework, and you can also use Symfony or another one. I think all of these frameworks have a little bit of personality, and one which you like best is probably the one that matches your personality. I'm sensitive against bloat in my code. I want my code to be very expressive. The naming should be good and easy to use. The API should be very human to me, even if that means we’re not following certain principles anymore.

What I mainly do to help popularize Laravel is make open source packages. Every time I have functionality in one of my applications that I think will benefit others, too, I extract that to a package, so other people don’t need to program that functionality.

Examples of this could be, for instance, a good package to send a newsletter via MailChimp or maybe to send something to analytics, or maybe to have a very structured log of everything that is happening in your application.

My main involvement is in that program, but I also talk with people developing the framework. I let my opinions also be known there. It’s nice to be part of the conversation where Laravel goes broadly. I’m not the boss of deciding anything. But I think by just talking to people and voicing my opinion via my blog, I can make a little bit of a difference there, or at least share some perspective on how we could solve things.

How the PHP Framework Community Works

Viktor: I'm familiar with some of the communities and software foundations around big names like Apache, Eclipse Foundation and CNCF. What process is applied for communities governing development frameworks?

Freek: PHP is governed differently than how Laravel is governed. And I don’t want to say this or that is better. It’s just different. So with PHP itself, it’s very, very structured. In my opinion, it's a bit rigid, where only certain people who already have contributed to the language can do it again. There is a sort of voting and point system, and only certain people are allowed to vote on the proposed changes. But everybody can take part in the conversation.

Whereas with Laravel, it’s a lot more unstructured, I’d say. You might think that the Laravel team is very big, but it’s very, very small. It’s only, I think, eight people that are working full time on this. And basically, they decide what goes in and what goes out. And probably the final say in this is Taylor Otwell, the creator of the Laravel framework, who is still very active in developing it.

The community can voice their opinions too. There is a GitHub repository to the framework itself, where they have active discussions. And I know that Taylor and various members of the community, often of the Laravel team, are also keeping their eye out on Twitter, and they want to get a feel of what people need. It’s not strict or organized. It's much more organic than what PHP itself does.

Viktor: How do commercial projects look in the Laravel and PHP world? And if you want to develop something commercial, do you need to develop it as a separate project?

Freek: It’s pretty simple. Most of the things in the Laravel community, which are open source, do have the MIT license, so it’s no problem to just use that in your own projects.

Viktor: The MIT license is very permissive. The only requirement is that you need to have the header with the initial authors of the library if you’re trying to use it everywhere. Still, you cannot force liability to original authors, which is also cool. You keep the name; you keep the fame that you created this. However, they cannot blame you if something doesn’t work or brings you some financial losses and things like that—the splendors and miseries of open source.

Freek: It sounds like the perfect license, right?

Viktor: Yeah, I use it for all my personal projects. I don’t mind sharing the knowledge because I’m not planning to make some money anytime soon. I’m making money by working and helping others. But I also want to have my name somewhere that "Viktor did this." So that’s my personal license of choice. I usually don’t think much if I'm doing something for myself. But if I do something for work, usually it’s an Apache V2 license because of the standards some companies use.

Freek: I think MIT is just perfect and neat to make your name. And yeah, this is a topic of its own, really. But once you’ve made your name a little bit where you have an audience, then you can start thinking about selling something to your audience.

About Spatie

Freek: Spatie is a Dutch word. So Dutch is the language that is spoken in Belgium. And it’s basically the blank character in between words. I think it’s called in English: a space.

Viktor: OK.

Freek: Why did we name the company this way? We only targeted Dutch companies at the beginning of our company, and we did a little more than web design. It was also photography and styles. And our tagline was "It’s between everything. Spatie." That was a little bit of the word joke we had. Right now, it’s a little bit more difficult because we only do web design, and our main audience isn’t Dutch anymore, but we still decided to keep the name because it has so much personality going on as Spatie.

Viktor: I like it a lot. How did you and your friends create the company?

Freek: I wasn’t the original founder of the company. That was my colleague, Will. He started a couple of years before me and did some small websites focused on design. He had some clients that wanted more features and functionality. He knew I could program a little bit. So he asked, “Hey, why don’t we do this together?”

We asked another buddy to handle all client contacts, and then basically Spatie, in the core of its current form, was born. Just a team of three who could do more complex websites than they could do on their own.

Why Laravel?

Viktor: And how did you choose Laravel for your framework?

Freek: For a couple of years, we used Zend Framework. Around 2014, maybe 2013, we were getting a little tired of PHP. PHP was a little bit in a precarious position, I would say. There wasn’t a good dependency manager, or we didn’t know it at the time, at least.

PHP, the language itself, also didn’t have yearly releases yet. And we were mainly taking a look at Ruby. It seemed that that community had all the fun where all the nice features were being developed, and we made a couple of Ruby sites.

But then I stumbled upon a blog post about Laravel, and it showed some code snippets on how you could define a model and define a route in an application. And it immediately grabbed my attention because it was so much easier than the Zend framework we used before.

So I checked it out. I was pretty amazed by the documentation already there in an early stage, and I just started tinkering around with it. And I still remember after only a day of tinkering, I said to my colleagues, “Hey, we need to use this.” Because in those days, we were tinkering a little bit with Ruby and Ruby on Rails, but we were still very much newcomers to it. But PHP, we did know. So it was very easy for us to also know Laravel, and it made perfect sense for us to jump back from Ruby to Laravel.

And it’s just because of the expressive nature of how Laravel is programmed that we chose to take a gamble on it. Laravel was still seen as the little toy framework that you shouldn’t build real applications with. But yeah, we made a gamble, and it turned out pretty good for us.

Viktor: With this community of modules, what are the drivers for those modules? Like are there enough modules to go there and just compose your application?

Freek: Yeah.

Viktor: What are you working on as a software engineer at Spatie? And what is your community involvement like right now?

Freek: Right now, I’m mainly working on paid products that we make at Spatie. I stopped doing client work two years ago. These days I work on our own products and video courses of our own. I also take time to create open source packages because, as I’ve said, we still do client work in our company, and we still find functionality in that client work that we can open source. And I very much like to create packages that contain solutions for these kinds of problems. I have a dream job because I can decide what to work on myself.

I also like to write on my blog, so I also get involved with the community, voicing my opinion on certain things and sharing how I’ve solved certain problems in our applications.

Demo: Debugging PHP With Ray from Spatie

In the last part of the episode, Freek demoed Spatie's debugging tool, Ray, which has a paid component and an open source component. In the PHP world, there are basically two ways of debugging. On the one hand, you have a full debugger experience. And the other way is just dumping statements to the log, screen or your console. Ray is something in between those.

Thanks for Joining Us!

I hope you'll join us again on February 7 for our next Kongcast episode with Jeff Taylor from Okta.

Until then, be sure to subscribe to Kongcast to get episodes sent to your inbox (and a chance to win cool SWAG)!