PHP marketplace: The developer’s guide
Considering building a marketplace with PHP? Comparing marketplace PHP scripts or software? Worried about the drawbacks or looking for alternatives? This article is for you. Written by Sharetribe’s senior full-stack developer Mikko, it’s the complete developer’s guide to everything you need to know about building a marketplace with PHP.
Table of Contents
- Introduction: Why a PHP marketplace?
- Potential challenges with marketplace scripts and eCommerce builders
- How to build a marketplace with Sharetribe Flex + PHP
- Conclusion: Start building your marketplace
Introduction: Why a PHP marketplace?
A few thoughts on the popularity of PHP marketplace solutions and scripts.
An online marketplace has the potential to grow into a tremendous, global-scale business.
But building a marketplace platform is a big undertaking. One solution to speed up the process and leverage the potential of marketplaces comes in the form of PHP scripts and PHP marketplace software.
An eCommerce marketplace has great growth potential
The online marketplace boom shows no sign of slowing down. In 2020, sales on the top online marketplaces were worth $2.67 trillion. By 2024, sales are predicted to go over $7 trillion. That’s a big window of opportunity.
The marketplace model is tempting for eCommerce entrepreneurs for many reasons.
In a nutshell, an online marketplace brings together two sides of a market, the supply, and the demand. The platform owner facilitates their transactions and typically makes money through commission or another marketplace business model.
This two-sided marketplace model has tremendous benefits. It requires no initial inventory from the marketplace entrepreneur. It makes the experience of buying and selling efficient, convenient, and transparent. It has the potential to generate network effects that can become a massive growth lever for the business.
Developing a marketplace platform from scratch continues to be a big, complex project. Luckily, there are great alternatives for marketplace website development apart from building one from scratch. Which brings me to the next reason why PHP marketplace solutions have been popular in recent years.
A PHP marketplace script or software can save you time and money
Marketplaces are much more complex sites than traditional eCommerce stores. I’ve written about the specificities of marketplace functionality in more detail in this article. But the tl;dr would be that because there are two distinct user groups, everything from managing user-generated content to designing the exact transaction process becomes more challenging. Marketplace payments are particularly complicated, as there are all kinds of technical and legal hurdles to overcome.
From the perspective of a developer, most of the must-have marketplaces are also pretty boring to build. Essential marketplace website features like listings, profiles, messages, online payments, and admin features are essentially the same on any marketplace. They’re the stuff users nowadays take for granted. And yet, building them will take the bulk of a dev’s time.
Using a marketplace script can save you lots of time by giving you some of the complicated-but-boring-yet-essential features out of the box. This is a big benefit, because it frees up your time to build the features that make your business unique.
PHP is a practical coding language for getting stuff done
Even if the golden era of PHP might be in the past, the language is anything but abandoned. There was a major version release of PHP 8 in November 2020. And big companies like Facebook, Lyft, Tumblr, Slack, Etsy, and MailChimp continue to use PHP in their infrastructure.
PHP has been around for a long time – since 1995, according to Wikipedia. So we're talking about a mature language for sure, and a language with a big user community. When the time comes to expand your team, finding a PHP developer won’t be an issue.
PHP is a mature coding language with a big user community.
Many developers enjoy working with PHP because it’s one of the easiest languages to learn. And it offers a good set of frameworks you can choose your favorite from: Laravel, Codelgniter, and Symphony being the most popular. PHP frameworks implement commonly used functions and save you from writing every bit of code from scratch.
In short: while PHP may not be the most elegant coding language nowadays, it remains a practical language for those who want to get things done.
There are plenty of PHP marketplace scripts and PHP marketplace software out there
There are lots of marketplace solutions out there powered by PHP. Some people refer to them as scripts, others as marketplace software solutions or marketplace platforms. In the end, these terms mean roughly the same thing, but there are lots of differences between individual products offered. (The next chapter of this article will help you with comparing the offering.)
A marketplace script or software solution is essentially an application that powers a set of marketplace features.
Some are available to download and install on your own server, either for a one-off fee or completely for free if you find an open-source marketplace solution. Places like CodeCanyon, for example, let you find scripts for different marketplace types, and many scripts have online demos you can test. After installing the script, you typically need to customize it using the coding language it was built on – in this case, PHP.
A PHP script is an application that powers a set of marketplace features.
There are also PHP-based eCommerce software solutions that are available as no- or low-code Software-as-a-Service products. They have a graphic UI you can use to adjust the features and set up your marketplace, and many offer some level of hosting, maintenance, and technical support. Some of them are also offered as more customizable or open-source alternatives.
For example, CS Cart is a downloadable eCommerce solution that has a multi-vendor version to power online malls. It has a one-off downloading fee. The more features you want included, the bigger the price tag. You’ll then host the solution on your server, after which you can customize the software either using the built-in no-code tools or through code.
Magento Commerce is an eCommerce store builder, on top of which you can buy a multi-vendor extension to get the basic two-sided functionality. It’s offered both as a hosted cloud solution, where pricing is based on Gross Merchandise Value and Average Order Value, and an open-source version with a more limited feature set.
Finally, you can build a marketplace with WordPress using the WooCommerce plugin for the online store functionality and a plugin for multi-vendor functionality. You can read more about this approach in this article.
To sum up: if you decide to use a PHP-script or an ecommerce builder to power your marketplace, there are plenty of options you can compare and choose from.
Sharetribe Flex is a headless marketplace solution that we developed to combine the best aspects of all approaches. It’s fast to launch and effortless to maintain. It’s built from the ground up to be fully customizable – it makes even challenging development projects like iterating on marketplace transaction processes a breeze. It puts developer experience front and center.
If you’re interested, skip ahead to chapter 3 where I share the steps of building a Flex-powered marketplace with PHP, along with a code example for calling the Marketplace API with PHP that is copy-paste ready.
Potential challenges with marketplace scripts and eCommerce builders
Things to consider when choosing a PHP marketplace script.
Depending on your future plans and goals for your business, there are some questions worth considering already at the early stages. These questions can also help you compare the offering and choose the best script or software solution for you.
Is your marketplace type supported?
A big chunk of the essential marketplace functionality works for almost every marketplace idea, niche, and market. But one thing plays a big role here: your marketplace offering type.
“Online malls” like Amazon ship relatively low-value items from multiple sellers across the globe. They need a shopping cart with a multi-vendor checkout and great features to support shipping and inventory management. They might get by with one-sided reviews (only the customers review the sellers). Building a peer-to-peer product marketplace like Etsy introduces more two-sided feature requirements.
If your marketplace offers rentals (you're building a website like Airbnb) or services (you want to build a website like Fiverr) are different. They have no use for a shopping cart or shipping. Instead, what they need is a great booking calendar, an availability management feature, and location search. Two-sided reviews are a must – both customers and providers need a guarantee they can trust the other party.
To make things more complicated, a marketplace for selling single unique, high-value products (like works of art, vehicles, or apartments) might in fact work more like a rental or service marketplace than a product marketplace, from a strictly feature-set-point-of-view that is. The audience type might play a role as well – peer-to-peer marketplaces need different features than B2C businesses, not to mention B2B marketplaces with complicated, multi-sided transaction flows.
Thinking about your marketplace idea from this perspective helps you with choosing the best starting point for your platform. For example, big eCommerce players like CS-Cart, Magento, and WooCommerce are designed for the “online mall” starting point and might be more challenging to customize into powerful service, rental, or job marketplaces.
How are payments processed?
Marketplace payments are about as complicated as online payments get. Both from a technical point of view and a legal one.
First, your customers want to check out easily with the payment method they prefer. Different methods require vastly different processes. Then, the customer’s payment needs to be split into your marketplace commission (if that’s your revenue model) and the payout your provider gets.
Marketplace payments are about as complicated as online payments get.
You probably want to delay paying the provider until they’ve delivered what the customer bought — a process that is subject to all kinds of regulatory and technical challenges. Finally, paying the provider requires going through a Know Your Customer process to comply with anti-money laundering legislation.
Different PHP scripts and eCommerce solutions handle payments differently. At the very least, make sure they allow you to process payouts to the sellers without the money going through your own bank account first. Otherwise, you might step into a legal jungle as in the eyes of regulators, you’re acting as a bank and depositing your seller’s money without the required legal compliance.
These questions should impact your choice of marketplace solution. But it’s also a question of choosing the right marketplace payment service provider and deciding on the right kind of payment integration. I’ve written about integrating a 3rd party payment gateway at length in our Flex documentation. The article can be quite useful even if you’re not building your marketplace with Sharetribe Flex.
Is the transaction process customizable?
Your marketplace transaction process (or transaction flow) includes online payments – and much more. The transaction flow includes all of the steps your customers and providers need to take to complete a transaction. From their very first point of contact, through messages and booking requests, all the way to a successful payment and review.
The process also needs to include other possible outcomes. What if the provider doesn’t accept the booking on time? Can both the customer and the provider cancel a booking at any time? What happens if the payment process fails? What if the customer asks for a refund?
Our CEO Juho’s article about designing your marketplace transaction flow can help you figure out your requirements. This piece of Flex documentation can also help regardless of the technology you choose.
When you’re choosing a PHP marketplace script, pay attention to how well the default transaction process can be customized. A fixed process with a simple “add to cart” -> checkout -> profit flow can be tough to customize to support everything you want from your marketplace.
Another important point: you’re guaranteed to want to customize your transaction process as your business grows. At least in my experience, this is the part that entrepreneurs iterate on the most and where the biggest potential gains are in terms of conversion rate optimization.
So in addition to being offering a customizable transaction process, check that the script supports editing the transaction process while your marketplace is live and there are ongoing transactions. If you can’t have multiple transaction process versions live simultaneously, you’ll effectively have to close down your marketplace for several weeks if you want to make the slightest change to your transaction process. Having the ability to have multiple different transaction processes for different order types is a great feature as well.
I’ve written a detailed article about the essential features of marketplace apps that discusses transaction processes in more detail, you can find that here.
Is marketplace the core offering?
Related to the previous points about transactions processes and payments: marketplaces are a lot more complicated applications than online eCommerce stores.
Usually, my recommendation is to choose a software solution or a script that was specifically built for powering online marketplaces. If the word “marketplace” isn’t mentioned on the front page, and instead words like “multi-vendor eCommerce” are used, that may indicate that the support for multiple sellers was added as an afterthought. But building a multi-vendor marketplace is not as simple as adding seller profiles to an eCommerce store. A tweaked online store solution may not be ideal for powering a competitive marketplace platform with plans to reach a significant scale. Or at the very least, you’ll need to do heavy customization.
Choose a dedicated marketplace solution if your goal is to compete at a significant scale.
I have some bias here because Sharetribe’s products are specifically built for creating online marketplaces, and the benefits are clear in my book. But there are some PHP-based marketplace scripts and software solutions available that take a marketplace platform as a starting point, too.
How is the developer experience?
When you’re starting a new marketplace business, the best move is to work with the MVP mindset and launch as fast as possible. But sometimes, a platform needs a powerful custom feature from the get-go. That might mean trading speed with a better UX makes sense.
But having to delay your launch because you’re too busy debugging or navigating a messy codebase that wasn't built with customizability in mind? Unacceptable.
When you choose your PHP marketplace script, make sure it’s a joy to work with. Check things like:
- Are there lots of features you don’t need? These will over-complicate the code.
- Are there interdependencies? Does changing one feature require updating everything else?
- How is the quality of documentation?
- Is expert technical support available? Will it be available throughout your project?
Though this is time-consuming to estimate (and compare – good to check at least a few candidates to get a sense of the standards), I really recommend taking the time. Check the demos, download the code if there’s a free trial, read through the documentation, and test the support with challenging questions.
The time you spend here will pay back multiple times over the course of building, maintaining, and improving your marketplace.
But does it scale?
Though I just recommended the MVP-approach, sparing some thought for the future is warranted.
The big question here is does the PHP marketplace solution have an API, and do you need one. If you want to build a mobile app and/or integrate third-party tools (say for marketing automation, CRM, shipping, notifications, payment methods, or the like), an API is pretty much a must.
If you’re working with a marketplace script where you’re in charge of hosting both the frontend and the backend databases, large listing images, and search indexes, maintenance is another concern. How do you estimate the cost, both in terms of money and time, of hosting and maintaining a platform for 10,000 users? 100,000? 1,000,000?
Security and performance are also worth a thought. If you suddenly get mentioned on the front page of HackerNews, do you have sufficient monitoring and maintenance capability to handle the traffic spike? Or the more negative potentiality, where a rogue player notices the spamming opportunities of your growing marketplace. What if a plugin fails, or if online payment or data security regulation changes?
Everything I’ve said about customizability and developer experience applies here, too. If it’s possible, avoid creating a situation where scaling your business will require building a completely new platform from scratch.
How big is the upfront investment?
The price range in marketplace PHP scripts is big – from a few bucks to several thousands of dollars per project. The bigger the upfront investment, the more careful I’d be with finding answers to the questions I’ve listed above.
Another challenge of the one-time fee model is that PHP scripts can get outdated quite fast. Are maintenance and updates included in the one-off fee, or are you responsible for the entire codebase after you’ve bought it? If something breaks and fixing it is not included in the fee, how big a hit will your budget take?
Subscription-based models have one advantage over one-off fees: the marketplace software provider has skin in the game. To retain your business, it’s in the software partner’s best interest to maintain your platform at top performance level and add updates that boost your growth.
Is the script your fastest way to launch?
As I mentioned earlier, most entrepreneurs will benefit from launching their business as fast as possible. That gives them the opportunity to validate their idea before spending months building, find out what works and what doesn’t, and iterate if needed.
If fast validation is your goal, starting with a no-code marketplace SaaS tool like Sharetribe Go could be an option worth considering. Our customer Mike chose this route over alternatives that required coding, exactly because he wanted to optimize for speed. He launched in one evening, posted to Product Hunt a week later, and got his first 1,000 users in a matter of hours.
Launch your marketplace as fast as possible.
Sometimes, the features of no-code tools aren’t enough. A future-proof solution like Sharetribe Flex might then be a great alternative to a PHP script. That's also what Mike chose – after validating his idea with Go, he moved his platform to Flex to grow it further.
If you’re interested in giving Flex a try, you can sign up and get full access to the development environment for free. We won’t ask for your credit card details before you’re ready to launch your site.
Next, I’ll go through this process step by step and share a code example for calling Flex’s marketplace API with PHP.
Sharetribe Flex gives you all the essential marketplace features out of the box. These include a flexible transaction engine, secure online payments, customizable data storage, a powerful set of marketplace admin features, and more.
You can take the backend to use by building a marketplace user interface in PHP and connecting it with the backend through Flex’s Marketplace API. Here’s how.
If you were building a marketplace with PHP from scratch or with a script, at this point you’d need to set up your database and configure email sending.
With Flex, you don’t need a database. The Flex API handles storing large images, listings, users, transactions etc. In addition, Flex provides extended data to store data that is specific to your marketplace type. You can go really far without ever needing your own database.
Choose your framework (example: Laravel)
PHP has a wide variety of frameworks available. I recommend using a PHP framework for several reasons:
- PHP frameworks have good documentation available.
- PHP frameworks have built-in security features.
- Coding conventions, directory structure, and so on are pre-built, so you don't need to start completely from scratch.
- Most frameworks contain features that you will need when building your marketplace front-end, such as routing, view templates, sessions (cookie data management), data validations, error handling, and logging.
Laravel is a popular PHP framework that contains the important features I listed above. It offers a minimal API around the Guzzle HTTP client, which you can use to interact with the Flex API.
Use a PHP framework to speed up development.
Another benefit of Laravel is that it’s a full stack framework. It has support for rendering the views with Blade templates or Inertia.js. For example, Inertia lets you build a marketplace application that feels like a single-page application, with fast page changes without full page reload, without the complexity of having to actually build one.
I won’t go into the details of using Laravel in this article (check out their great documentation for more info). But later in the code example, I’ll demonstrate how to call Flex API directly with the Guzzle HTTP client. The example should be fairly easy to convert to use Lavarel's Guzzle HTTP Client facade.
Build your PHP marketplace user interface
Flex offers you a JSON API that you can use with PHP. Through the API, you’ll have access to all of Flex’s powerful marketplace features.
The thing that is left for you to build in PHP is the marketplace UI. With a good PHP framework, the process of building the MVP marketplace UI can be quite fast with a good PHP framework.
On the UI side, a few elements you’ll definitely need from day one include:
- User login, sign up, password reset
- Posting a new listing
- Listing editing
- Listing search and listing details
- Transaction/messaging/payment UI.
In addition, you might already want to build:
- User profile editing
- Landing page
- User Inbox
- Static pages, i.e. About, Privacy, Terms of Services.
Naturally, you’ll need a nice design for your UI. Here, we can offer you a shortcut. Take a look at Flex’s marketplace web app design files in Sketch and copy as much as you like!
How to use the Flex API from PHP
In these examples, we'll use a popular Guzzle HTTP client. When using Laravel, you can use Lavarel's HTTP client facade, which uses Guzzle Client under the hood. For the purpose of this article, we'll install Guzzle directly with composer.
After you've created the Flex account, you will be redirected to Flex Console. Head to the Build > Applications page, where you can find your marketplace's unique Client ID.
After you have installed Guzzle, you need to require it, set your marketplace's unique client ID, and create a new Guzzle client instance. Here's how:
Now that you have an HTTP client that you can use to call the Authentication API, you need to authenticate. Every request to Flex’s API needs to be authenticated by an authentication token. Here's how to issue an authentication token for an anonymous user:
We called the Authentication API to issue an access token and stored it to $anon_access_token variable.
Now that you have the access token, you can use it to make requests to the Marketplace API. But first, we need to initialize a Marketplace API client the same way we did for Authentication API:
The newly-created Marketplace API client uses the anonymous access token to authenticate itself.
Now, let's use the new Marketplace API to query all listings in the marketplace:
As you can see, the marketplace doesn't have any listings yet. So let's create some! But before that, we need to sign up as a user who will become the seller of that new listing.
First, we'll create the user. Let's call him John:
After that, we'll log John in. This needs again the Authentication API:
In the example above, we logged in as John using his email and password. In the response, we received the access token and stored it to the $john_access_token variable. We will use this token to make subsequent requests as John. In addition, we received a refresh token. The access token is valid for 10 minutes only. After that, you need to issue a new access token using the refresh token.
Now that we have an access token for John, we can again make a new Marketplace API client that will call the API as John.
Next, we can create a new listings. Let's imagine our marketplace is a sauna rental marketplace. An API call to create a new sauna listing might look like this:
In the API call above, we created a new sauna listing for John with quite a bit of details. The listings has a title, description, location, availability plan, price and some additional free-form data (called Extended data) for address and amenities.
The availability plan describes a listings default weekly availability. In this case, the sauna is open from Monday to Friday and it has room for 10 people. Except on Friday, when there's extra room, for 20 people in total.
Now, let's try to search some listings again. This time, we'll add some search parameters. We want to find a sauna for next Monday with enough room for 15 people:
Even though we just created a new listing, the listing search returns an empty set of search results. The reason is that our newly added listing only has room for 10 people on Mondays according to its availability plan.
So let's try to tweak the search a bit. Since we need to find a sauna for 15 people, we might try to reschedule the sauna event a bit. Would there be saunas that could fit 15 people next Friday? Let's try:
There we go! We found our sauna, since it now matches the search criteria. There are plenty of other search parameters available, e.g. search by keyword, location, price etc.
This was a quick introduction how to use Flex API from PHP. Please have a look at the API reference document for full documentation about all the available endpoints.
Launch your marketplace!
After you’ve built your marketplace user interface in PHP and connected it with the Flex backend, it’s time to go live. This is the point where Flex introduces a monthly fee – the development stage is free for an unlimited time.
Building a marketplace is a process, not a project.
Before going live, you need to pick a web hosting for your PHP user interface. Flex takes care of hosting the backend. There are plenty of PHP web hosting services available, most of them quite affordable. We at Sharetribe have had a good experience with Heroku, so their PHP hosting is our recommendation.
Building a marketplace is a process, not a project. The launch is only the beginning! My colleagues in Sharetribe’s support are there for you every step of the way. We also have a big library of resources that offer practical advice for different stages of your marketplace journey. A good starting point is our Build a marketplace guide.
Conclusion: Start building your marketplace
My final piece of advice: start today.
In this article, I’ve listed several reasons why PHP marketplace scripts and software are popular solutions for building an online marketplace. I’ve also listed some challenges you might encounter while choosing a script, and tried to give advice that will help you choose the best possible marketplace solution for your business.
Naturally, I hope you’ll give Flex a try and test the code examples I’ve written in action (if you do, let us know how that worked out – that’s @sharetribe on Twitter).
Whichever approach you choose, my final word of advice would be: start today. Whether it’s checking out a script or creating one free trial, that’s a great start that already moves your thinking forward. Building a marketplace may seem like a daunting task, so commit to an iterative process of building, learning, and improving. Launch fast, learn fast, and validate as you go.
Best of luck with your marketplace project!