Thoroughly Modern: What’s New With PHP On IBM i?
December 7, 2020 Timothy Prickett Morgan
If you use PHP on IBM i, you’ve likely seen some recent announcements about some great changes coming to the open-source language. According to the latest blog post from Zend on PHP 8, there are a number of new functions being introduced including str_contains, str_starts_with, and str_ends_with, preg_last_error_msg and get_debug_type. In addition, the core PHP 8 engine has many new features, optimizations and improvements in the type system, error handling, and consistency. The key areas include:
- JIT Compiler
- Fatal errors on incompatible method signatures
- LSP Enforcement
- Resource “Classes”
- Assertion behavior
- XML-RPC is now in PECL
- Reflection changes
This is good news news for IBM i companies, and Marc Hunter, vice president of innovation at Fresche Solutions, comments: “PHP is getting faster, and is providing developers with increasing options to improve the both the capabilities of their programs and the quality of their code.”
This update comes shortly after Zend announced that it would discontinue Zend Server Basic in favor of a new, free Community PHP distribution. Marcel Sarrasin, chief product officer at Fresche, sees this as a positive change for the IBM i market. “People now have more options to move forward with PHP,” he says. “If you’re looking for a supported environment with additional troubleshooting features, Zend Server Professional or Enterprise would be great for you. If you’re looking to get started and try it out, there is a great article from Zend that walks you through how to get started and install Community PHP for the IBM i platform. Seiden Group also has a soon-to-be-released CommunityPlus+ PHP which will give another option for using PHP on IBM i.”
Why Choose PHP for IBM i Web Development?
Providing high-quality digital experiences is key for most businesses, but organizations that run applications on IBM i have the unique challenge (and advantage!) of having an abundance of options when it comes to the technology they decide to use. Most of us are trying to do more with less these days and choosing the right tool for the job is key.
PHP is one of several open-source languages that is supported on IBM i. According to the most recent TIOBE index, PHP is the eighth most commonly used programming language around the world. The 2020 HelpSystems Marketplace Survey also revealed that it’s a popular choice for new development on IBM i, with 21% of respondents indicating that they use PHP.
With a 25-year history and over 14 years of support on IBM i, it makes sense that PHP is widely used by IBM i organizations. “Proven technologies are what people tend to adopt and we build for what the market wants,” says Sarrasin. “That’s why Fresche has focused so heavily on PHP. We’ve offered PHP solutions since 2009, and we’re seeing that adoption continue to grow in our customer base because it’s a proven language.”
The learning curve from RPG programming to PHP (compared to other languages) is also typically considered an advantage when IBM i shops are looking at web development. Sarrasin says: “RPG programmers can succeed at it, and I think that’s a big strength – in addition to being stable and optimized for the web. If you happen to hire PHP developers, it’s easy for them to understand IBM i, the database and get going. So different types of developers are able to succeed with it.”
Hunter agrees: “There’s millions of snippets of example code, there’s millions of PHP developers, there’s tons of extensions, tons of frameworks, tons of tools. The wealth of practical information out there on PHP is vast. So that really greases the on-ramp for an RPG developer.”
How Are Modern Organizations Using PHP on IBM i?
Cross-platform portability, integration and the continued proliferation of web technologies are all big plusses for organizations who are looking to provide web and mobile experiences for their customers. Most of the time, Fenton uses PHP to create APIs, where in the past she might use PHP to also create the front-end. “Front-end frameworks are faster, more scalable and look cooler. They’re the new way of developing and they provide a multi-tiered separation-of-concerns architecture.”
One client, for example, partnered with Fresche to develop a mobile-friendly B2B eCommerce site that runs on IBM i. The horticultural broker’s website is written with PHP on the back-end, accesses DB2 data, and uses Bootstrap, a responsive open-source framework, for the front-end.
“Depending on the client, some PHP clients will have us access their database directly through PHP, and sometimes we’ll access it through stored procedures. There are a few ways to get at the database. It might be direct or they might want one more level of separation. One advantage is that this provides another layer of security. Another reason why we might do this is because stored procedures (or RPG programs) can be written and maintained by the client who would be familiar with those frameworks. This empowers them to manage the data and the business logic in a language they’re familiar with. Then we expose that to the web with PHP.”
There is a drawback to this more advanced approach: A client would have to learn multiple languages for the back end and front end, which could seem difficult for some programmers who are just beginning to develop for the web. But that’s the beauty of PHP: You can take a simpler approach if you are new to PHP and web development. This enables RPG programmers to use structures and concepts that are familiar to them rather than undertaking a larger paradigm shift required by technologies like Node.js and its asynchronous, event-driven approach.
On the flip side, this is the recommended model in terms of future proofing your application. Separating the different areas of your application enables you to replace the front-end with a different front-end, for example, without changing your back-end logic. Conversely, you could change all of the business logic without touching the front-end. The application performs better as well because you’re not transferring and building HTML back and forth to the server. All of that is done client-side and the only thing passed over to the server is data.
PHP Development Options
When you choose to work with a mature language like PHP, you also open up doors when it comes to tooling. There are an abundance of solutions in the market to help developers from a productivity perspective when it comes to coding PHP.
Fresche’s WebSmart solution includes templates that are designed for RPG programmers. The templates automatically build the front-end and back-end code for you, and they enable you to connect to your existing business logic on IBM i. “This gives you quick results with PHP and it can grow in complexity as you grow,” says Sarrasin. “We have multiple templates that are suited for skill sets so WebSmart grows with you.”
WebSmart also includes a productive IDE with standard productivity features (syntax checker, code completion and a debugger), but it also has features that appeal to RPG programmers, such as IBM i integration and a wizard to call RPG programs. “There are a lot of high-quality editors out there,” says Hunter (who was involved in the initial development of WebSmart). “Choosing the right editor unlocks all kinds of productivity features from change management to unit testing frameworks to code comparison and peer code review frameworks. That’s one of the reasons why I would encourage an RPG developer to make that transition to PHP. Aside from the language itself, you’re unlocking a mature and varied ecosystem that supports this kind of development.”
Fresche recently announced that they are now able to transform RPG to PHP. This is good news for IBM i shops who are looking to transition their existing applications to a modern, portable language. Transforming existing applications to a modern language such as PHP is an effective way to enhance these core applications while embracing open source, cloud, web and AI technologies. They recently covered these details in a webinar, which you can watch here.
What would the folks at Fresche say to organizations considering PHP for IBM i development?
Fenton says, “It’s a great choice because it’s a simple language to learn, it’s easy to install on IBM i, and there’s a huge base of knowledge for PHP in the world. If you don’t know how to do something, it’s probably been done already by somebody else and you can just copy it.”
Hunter says, “We talk about how easy it is to make the jump from RPG to PHP. You can start by coding PHP the way you code RPG, but this should be first a step and then you should up your game in terms of how you approach problem-solving.”
Fresche is hosting a webinar about the recent PHP changes with Perforce’s Erwin Earley on December 14. This is a great opportunity to brush up on what’s new and look at some of the options that are available for IBM i organizations. You can register here.
This content is sponsored by Fresche Solutions.