PHP MicroServices Examples

Overview

PHP MicroServices Examples

This is a repo of example MicroServices using PHP. Areas of topics will include:

  • Socket Programming
  • RabbitMQ Example
  • RESTFUL Example
  • Authentication and Authorization Example
  • Functional Programming Example

Many of the examples use ProdigyView Toolkit for development.

Requirements To Run Test

  1. Composer
  2. PHP7
  3. PHP Sockets Extensions Installed

E-Mail and Socket Programming

Overview

The mail microservice uses basic socket communication between a socket server and service. For explanation, please read: PHP Microservices — Send Emails Over Sockets

How To Run

  1. Go to the email folder
  2. Run composer install to install required packages
  3. Open up two tabs in your console
  4. In one tab, run php server.php
  5. In the other tab, run php client.php

Video Processing and RabbitMQ

Overview

The services shows a basic example of how to create a service for processing videos with RabbitMQ. For detailed explanation of the service, please visit: PHP Microservices — Video Processing With RabbitMQ

How To Run

  1. Ensure RabbitMQ is installed and running locally
  2. Go to the video folder
  3. Run composer install to install required packages
  4. Open up two tabs in your console
  5. In one tab, run php server.php
  6. In the other tab, run php client.php

Restful Crud API

Overview

This tutorial will demonstrate how to create a basic REST api for processing CRUD operation at an endpoint. For detailed information, please visit: PHP Microservices — Creating A Basic Restful Crud API

How To Run

  1. Go to the rest folder
  2. Run composer install to install required packages
  3. Open up two tabs in your console
  4. In one tab, we need to start a php server with php -S 127.0.0.1:8080
  5. In the other tab, run php client.php

Organizing Access To Microservices

Overview

This section will show how to organize and manage multiple microservices. The past 3 examples have been combined into one, with the addition of sending pushing notifications and image processing. The goal is to give each service their own resources, and organize calling them via REST API.

For detailed work through please read Organizing Access To Multiple Services.

How To Run

We will need four tabs to effectively run this example.

  1. Start your RabbitMQ Server
  2. Go the the multiple folder
  3. Run composer install to install required packages
  4. Have your four tabs open to this folder
  5. Start the webserver with php -S 127.0.0.1:8090 in one tab
  6. Start the notification server with php servers/notification_server.php in the 2nd tab
  7. Start the media server with php servers/media_server.php in the 3rd tab
  8. Execute the tests by running php client.php in the last tab

Authentication, Authorization, Functional Programming and Unit Tests

Overview

This part of the tutorials covers how to perform Authentication and Authorization between microservices. It also includes an additional information on how to do function programming and unit test. Accompanying tutorial are as followings:

How To Run The Microservice

Running this example requires 4 tabs on your console.

  1. Go to the security folder.
  2. Run composer install to install required packages
  3. Make sure your 4 tabs are open in this directory
  4. Start the web server with php -S 127.0.0.1:8000
  5. Start the authentications server with php authentication_service/server.php
  6. Start the purchase server with php payment_server/server.php
  7. Run the client with php client.php in the final tab

How To Run Tests

  1. Go to the security folder.
  2. Run composer install to install required packages
  3. Type ./vendor/bin/phpunit --bootstrap vendor/autoload.php tests/AuthenticationServerTest.php for Authentication Tests.

Socket vs HTTP Performance

Overview

This tutorial and test will bring you through comparing the performance of a RESTFUL API vs Sockets. You may read along about the tests here: REST vs Socket Performance Benchmarks

How To Run

This test will require that 3 tabs open.

  1. Go to the socket_vs_http folder.
  2. Run composer install to install required packages
  3. Have your 3 tabs open
  4. In your first tab, start the web server with php -S 127.0.0.1:8000 -t http_server/
  5. In the second tab, start the socket with php socket_server/server.php
  6. In the final tab, run the client with php client.php
You might also like...
A PHP framework for web artisans.

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

The Symfony PHP framework

Symfony is a PHP framework for web and console applications and a set of reusable PHP components. Symfony is used by thousands of web applications (in

Open Source PHP Framework (originally from EllisLab)

What is CodeIgniter CodeIgniter is an Application Development Framework - a toolkit - for people who build web sites using PHP. Its goal is to enable

🚀 Coroutine-based concurrency library for PHP

English | 中文 Swoole is an event-driven asynchronous & coroutine-based concurrency networking communication engine with high performance written in C++

Yii 2: The Fast, Secure and Professional PHP Framework
Yii 2: The Fast, Secure and Professional PHP Framework

Yii 2 is a modern framework designed to be a solid foundation for your PHP application. It is fast, secure and efficient and works right out of the bo

CakePHP: The Rapid Development Framework for PHP - Official Repository

CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Associative Data Mapping, Front Controller, and MVC. O

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.

Slim Framework Slim is a PHP micro-framework that helps you quickly write simple yet powerful web applications and APIs. Installation It's recommended

High performance, full-stack PHP framework delivered as a C extension.

Phalcon Framework Phalcon is an open source web framework delivered as a C extension for the PHP language providing high performance and lower resourc

🚀 PHP Microservice Full Coroutine Framework
🚀 PHP Microservice Full Coroutine Framework

PHP microservice coroutine framework 中文说明 Introduction Swoft is a PHP microservices coroutine framework based on the Swoole extension. Like Go, Swoft

Owner
Pradeep Sahoo
Goal-driven and result-oriented professional with 10+years of significant, qualitative experience and expertise in different activities highly applicable to Web
Pradeep Sahoo
PhpBoot is an easy and powerful PHP framework for building RESTful/Microservices APIs.

?? tiny & fast PHP framework for building Microservices/RESTful APIs, with useful features: IOC, Hook, ORM, RPC, Swagger, Annotation, Parameters binding, Validation, etc.

tknet 656 Jan 4, 2023
Production ready Dockerfile for Octane powered Laravelish web services and microservices

Laravel Octane Dockerfile A pretty configurable and production ready multi-stage Dockerfile for Octane powered Laravelish web services and microservic

Exalab.co 245 Dec 26, 2022
Basic PHP app with Composer used in Microsoft Docs examples

page_type languages products description urlFragment sample php azure This sample demonstrates a tiny PHP app with Composer. php-basic-composer PHP sm

Azure Samples 3 Jul 14, 2022
PHP Kafka client is used in PHP-FPM and Swoole. PHP Kafka client supports 50 APIs, which might be one that supports the most message types ever.

longlang/phpkafka Introduction English | 简体中文 PHP Kafka client is used in PHP-FPM and Swoole. The communication protocol is based on the JSON file in

Swoole Project 235 Dec 31, 2022
FuelPHP v1.x is a simple, flexible, community driven PHP 5.3+ framework, based on the best ideas of other frameworks, with a fresh start! FuelPHP is fully PHP 7 compatible.

FuelPHP Version: 1.8.2 Website Release Documentation Release API browser Development branch Documentation Development branch API browser Support Forum

Fuel 1.5k Dec 28, 2022
An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols. PHP>=5.3.

Workerman What is it Workerman is an asynchronous event-driven PHP framework with high performance to build fast and scalable network applications. Wo

walkor 10.2k Dec 31, 2022
A multithreaded application server for PHP, written in PHP.

appserver.io, a PHP application server This is the main repository for the appserver.io project. What is appserver.io appserver.io is a multithreaded

appserver.io 951 Dec 25, 2022
Fast php framework written in c, built in php extension

Yaf - Yet Another Framework PHP framework written in c and built as a PHP extension. Requirement PHP 7.0+ (master branch)) PHP 5.2+ (php5 branch) Inst

Xinchen Hui 4.5k Dec 28, 2022
💫 Vega is a CLI mode HTTP web framework written in PHP support Swoole, WorkerMan / Vega 是一个用 PHP 编写的 CLI 模式 HTTP 网络框架,支持 Swoole、WorkerMan

Mix Vega 中文 | English Vega is a CLI mode HTTP web framework written in PHP support Swoole, WorkerMan Vega 是一个用 PHP 编写的 CLI 模式 HTTP 网络框架,支持 Swoole、Work

Mix PHP 46 Apr 28, 2022
Hello, this is simple attribute validation for PHP Models, based on the new features, presented in PHP 8

Hello, this is simple attribute validation for PHP Models, based on the new features, presented in PHP 8 It works as a standalone and can be use in custom projects or in libraries like Symfony and Laravel.

Ivan Grigorov 88 Dec 30, 2022