29
Fri, Nov
0 New Articles

TechTip: What Do You Need to Get Set Up to Do PHP on the IBM i?

Web Languages
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

 

PHP doesn't run in RSE or PDM, so how do you set up scripts (not programs) or do your testing? Do you need a PC? Or can you do it from the i?

 

RPG runs natively on the i. You create your program in a source file using PDM or RSE and then compile. Everything that RPG needs to do its thing is already built into the IBM i. PHP isn't like that. You need to do a little bit of work to get it to function.

 

I know you'd prefer to just dive into things. But you can't do that with PHP on the i because some effort is required to get it to work. So pay attention: this is important stuff.

 

Where Do You Work?

Let's start by discussing where you'll do your work. No one is hard-connected to an i anymore. We all work on either a desktop or a laptop that has some connection, generally a VPN connection, to an i. And when we do our work, it's done via an emulator that runs in Windows or whatever to create an environment in which we can work.

 

There are a couple of environments we'll use to do our PHP work: one to develop our programs in and one to run them with.

 

Where Do You Write the Program?

Let's start with where you write your PHP programs, although they're not generally called "programs." They're more often called "scripts" or "apps," where an app is a herd of scripts.

 

You do not create a QPHPSRC in PDM. Instead, you'll create your scripts using a basic text editor. Since you're working on a laptop whose operating system is a Mac (yes, correct answer), Windows (seriously?), or Linux (ya got your geek on), you'll have access to many different text editors. There will be a default one that comes with the operating system, but there are also lots of free ones out there that you can use.

 

Or you can buy one. Here's a hint: if you buy one for money, you'll probably get more functionality than if it were free. I use Text Wrangler, not because it's the best, but because it's free and I think the name is so cool. There are plenty of text editors that are better than this. What makes one text editor better than another? Mostly it's stuff that's oriented around one particular web language. For example, the ability to put end tags for an HTML document when you type in the starting tag. Or something similar for PHP. Google "text editors for PHP" and have a ball.

 

Oh, and I guess I should mention that Zend Studio is an excellent PHP text editor.

 

Bottom line, and this is very important, don't use Notes or Text Editor but don't spend too much time figuring out what text editor to use. None of them are going to write the code for you, and there are more important things to worry about.

 

So, what we know at this point is that you're going to need a text editor in which you will write your scripts.

 

Where Will You Run Your Scripts?

The first thing you need to remember is that PHP is a server-side language.

 

Web languages are either client-side or server-side languages. And the differentiation is based on where the language is interpreted. You can argue this and that, but PHP is, compared to RPG, an interpretive language. When it's time to run, the system figures out what it's supposed to do.

 

HTML, for example, is a client-side language. When the HTML script hits your browser, the browser figures out what needs to be done. PHP, on the other hand, is a server-side language. It's interpreted and processed when the script is received at the web server. The results are then sent back down to the client browser to be displayed. But the PHP thinking has occurred at the server.

 

I'm not about to go into all the reasons why some languages are client-side and some are server-side. That's a controversial and boring topic, but suffice to say that it's often a question of resources. PHP generally does more than HTML, for example, and doing that at the server-side, where there are more resources available, seems like a good idea.

 

I'm Sorry, Dave, but Is There a Point to This?

Of course. The point is that you can't just code PHP scripts and run them from your PC the way you would an HTML script. You need to set your PC up as a server because PHP is a server-side language, and that's where it runs. So you have to run it in a web server, not a PC client. The question then becomes, how do you convert your PC to a server? There are two basic ways.

 

The first is to download MAMP, WAMP, or LAMP onto your PC, depending on whether your operating system is Mac, Windows, or Linux. You can Google whichever version you need and download it for free. It's not hard; even I have done it. Works pretty well. Once you have it installed, all you have to do is start the app and then use the web page that it creates to test your scripts.

 

The second is to download Zend Server to the i you're working with.

 

Obviously, these two different options have different requirements. If you don't have access to the i (i.e., you're doing your PHP work on the down-lownot sure if anyone says that anymore; my street contact just started laughing when I texted it to him), then you can do all of this using MAMP, WAMP, or LAMP. Oh, did I mention that each of these is free? I like that myself and have used MAMP for a number of years.

 

But, if you have permission to download something to the i, then your best bet is Zend Server.

 

But isn't the Zend Server fabulously expensive? No, actually it's not. I'm not sure why, considering they have the exclusive with IBM, but it's really very reasonable because they offer several options. I believe I've covered their plans in other MC Press articles, and if I haven't, sue me. You can get a free copy of Zend Server, and it comes with a free year of upgrades and help line support. After that, you're on your own (and with PHP 6.0 coming up, you might want to have full support), but the free edition will get you going. And their help line is great at helping you get the whole thing set up, whereas with MAMP/WAMP/LAMP, you have to figure it out yourself.

 

Where Do We Go from Here?

Where we go next is to write an actual PHP script that you can run in your server environment and do something with. So your homework for the next month is to get yourself set up as a web server, either with MAMP/WAMP/LAMP or the Zend Server. I know, that's a rip-off because it should only be a couple of days work to get it set up, but it will be a month before the next TechTip. Sorry, but Lido sets the schedule, and you don't want to mess with that.

 

David Shirey

David Shirey is president of Shirey Consulting Services, providing technical and business consulting services for the IBM i world. Among the services provided are IBM i technical support, including application design and programming services, ERP installation and support, and EDI setup and maintenance. With experience in a wide range of industries (food and beverage to electronics to hard manufacturing to drugs--the legal kind--to medical devices to fulfillment houses) and a wide range of business sizes served (from very large, like Fresh Express, to much smaller, like Labconco), SCS has the knowledge and experience to assist with your technical or business issues. You may contact Dave by email at This email address is being protected from spambots. You need JavaScript enabled to view it. or by phone at (616) 304-2466.


MC Press books written by David Shirey available now on the MC Press Bookstore.

21st Century RPG: /Free, ILE, and MVC 21st Century RPG: /Free, ILE, and MVC
Boost your productivity, modernize your applications, and upgrade your skills with these powerful coding methods.
List Price $69.95

Now On Sale

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: