Skip to content

Jacked-PHP/sample-swoole

Repository files navigation

Swoole App Sample

by Savio Resende

This sample is for the Project Jacked PHP:

This is an App built on top of Slim 4.

Table of Contents

File Structure

├── docker
│   └── mysql_data
├── logs
│   ├── .gitignore
│   └── app.log
├── src
│   ├── Bootstrap
│   │   ├── App.php
│   │   └── Dependencies.php
│   ├── Commands
│   │   ├── GenerateFactory.php
│   │   ├── GenerateJwtToken.php
│   │   ├── HttpServer.php
│   │   ├── WebSocketServer.php
│   │   ├── Migrate.php
│   │   └── Seed.php
│   │   └── stubs
│   │       └── ModelFactory.stub
│   ├── DB
│   │   ├── Factories
│   │   │   └── UserFactory.php
│   │   └── Models
│   │       ├── Token.php
│   │       └── User.php
│   └── Events
│   │   ├── EventInterface.php
│   │   ├── UserLogin.php
│   │   ├── UserLoginFail.php
│   │   └── UserLogout.php
│   ├── Http
│   │   ├── Controllers
│   │   │   ├── Api
│   │   │   │   └── UserController.php
│   │   │   ├── AdminController.php
│   │   │   ├── HomeController.php
│   │   │   └── LoginController.php
│   │   ├── Middlewares
│   │   │   ├── AuthorizationMiddleware.php
│   │   │   ├── CheckUsersExistenceMiddleware.php
│   │   │   ├── JwtAuthMiddleware.php
│   │   │   └── SessionMiddleware.php
│   ├── Rules
│   │   ├── RecordExist.php
│   │   └── RecordExistValidator.php
│   ├── Services
│   │   ├── Events.php
│   │   ├── Hash.php
│   │   ├── JwtToken.php
│   │   ├── Resource.php
│   │   ├── Session.php
│   │   ├── SessionTable.php
│   │   └── Validator.php
│   ├── api-routes.php
│   └── routes.php
├── tests
│   ├── Feature
│   │   ├── ApiUserTest.php
│   │   ├── LoginTest.php
│   │   └── TokenTest.php
│   ├── Traits
│   │   └── SwooleAppTestTrait.php
│   ├── Unit
│   │   ├── GenerateFactoryCommandTest.php
│   │   └── GenerateTokenCommandTest.php
│   └── TestCase.php
├── views
│   ├── admin.php
│   ├── login.php
│   └── home.php
│   └── partials
│   │   └── chat.php
│   └── templates
│       └── admin.php
├── public
│   └── js
│       └── ws.js
├── .env.sample
├── .env.testing
├── bootstrap-phpunit.php
├── composer.json
├── composer.lock
├── docker-compose.yml
├── my-app
├── phpunit.xml
└── README.md

Installation

To run this app you'll need the following dependencies:

Step 1

composer install

Step 2

This step is to prepare the database. It can be skipped if you already have another DB source available.

docker-compose up -d

Step 3

Copy the .env.sample to .env and update the necessary configurations such as the database info, the log storage location and the session key.

Step 4

Run migrations:

php my-code migrate

Step 5

Run seeds:

php my-code seed

Step 6

To start HTTP Server:

php my-code http-server

Commands

This application executes commands through my-app PHP file. To see the full list of commands, run the following:

php my-app

HTTP Server

Start the HTTP server.

php my-app http-sever

WebSocket Server

Start the WebSocket Server.

php my-app ws-server

To start the WebSocket Server with an HTTP requests support on the same server:

php my-app ws-server --http

Migrate

Create database tables.

php my-app migrate

Seed

Populate the db.

php my-app seed

Generate JWT Token

php my-app generate:jwt-token

Generate a Model Factory

php my-app generate:factory

Tests

./vendor/bin/phpunit

Releases

No releases published

Packages

No packages published