A easy way to install your basic yii projetc, we have encrypt database password in phpfile, my class with alot funtions to help you encrypt and decrypt and our swoole server install just run ./yii swoole/start and be happy!

Overview

Yii 2 Basic Project Template with swoole and Modules


Yii 2 Basic Project Template is a skeleton Yii 2 application best for rapidly creating small projects, im using this project for build my API project.

The template contains the basic features including user login/logout and a contact page. It includes all commonly used configurations that would allow you to focus on adding new features to your application.

Latest Stable Version Total Downloads build

DIRECTORY STRUCTURE

  assets/             contains assets definition
  commands/           contains console commands (controllers)
  config/             contains application configurations
  controllers/        contains Web controller classes
  mail/               contains view files for e-mails
  models/             contains model classes
  runtime/            contains files generated during runtime
  modules/            Your direcoty with your modules, im using like this: API -> v1, v2, v3 etc.
  helpers/            A util classes for you, im build this for my encrypt class, Formater string and data etc. I hoppe you guys enjoy
  tests/              contains various tests for the basic application
  vendor/             contains dependent 3rd-party packages
  views/              contains view files for the Web application
  web/                contains the entry script and Web resources

REQUIREMENTS

The minimum requirement by this project template that your Web server supports PHP 7.0. theses extesions:

php73-json-7.3.18              The json shared extension for php
php73-pecl-swoole-4.4.18       Asynchronous & concurrent & distributed networking framework

INSTALLATION

Install via Composer

If you do not have Composer, you may install it by following the instructions at getcomposer.org.

You can then install this project template using the following command:

git clone https://github.com/tiagocomti/swoole-with-modules-basic.git

cd swoole-with-modules-basic

composer install

Now you should be able to access the application through the following URL, assuming swoole-with-modules-basic is the directory directly under the Web root.

CONFIGURATION

Your secret key

To generate a new secret for make a easy symmetric cryptography use this: ./yii byte-array/encode and write the new secret and paste it here: config/params.php. like this:

return [
'secret' => '{"1":95,"2":95,"3":95,"4":95,"5":95,"6":95,"7":95,"8":95,"9":51,"10":50,"11":98,"12":121,"13":116,"14":101,"15":115,"16":95,"17":110,"18":101,"19":119,"20":95,"21":107,"22":101,"23":121,"24":95,"25":95,"26":95,"27":95,"28":95,"29":95,"30":95,"31":95,"32":95}'
];

Database

after configure the new secret, you have to generate a new password for your database (encrypt one). For this, use it: ./yii data-base/crypt-pass and set your 32byte database password. Tip: for check your 32bytes pass, use: echo ________32bytes_new_key_________ | wc the return need be like this: 1 1 33

Edit the file config/db.php with real data, for example:

<?php

return [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=127.0.0.1;dbname=mydb',
    'username' => 'root',
    'password' => '{"1":111,"2":99,"3":114,"4":54,"5":71,"6":80,"7":119,"8":52,"9":51,"10":97,"11":97,"12":86,"13":89,"14":115,"15":84,"16":48,"17":83,"18":71,"19":112,"20":90,"21":88,"22":53,"23":70,"24":52,"25":66,"26":104,"27":109,"28":100,"29":100,"30":88,"31":65,"32":68,"33":47,"34":120,"35":57,"36":104,"37":104,"38":104,"39":109,"40":101,"41":85,"42":107,"43":83,"44":55,"45":83,"46":104,"47":116,"48":76,"49":80,"50":49,"51":114,"52":71,"53":49,"54":78,"55":50,"56":116,"57":71,"58":55,"59":121,"60":52,"61":110,"62":78,"63":84,"64":80,"65":105,"66":120,"67":101,"68":117,"69":50,"70":97,"71":79,"72":112,"73":51,"74":85,"75":100,"76":81,"77":113,"78":117,"79":115,"80":66,"81":104,"82":89,"83":72,"84":49,"85":50,"86":113,"87":99,"88":105,"89":66,"90":85,"91":114,"92":57,"93":65,"94":100,"95":111,"96":67}',
    'charset' => 'utf8',
];

Swoole

To start your own swoole server make sure you server doest use the port 9500. if is in use change the config/server.php port tag for a randon port you like

now, we need to configure a location for your swoole server like my nginx.conf

    location /apiswoole {
        	try_files $uri $uri/ @swoole_core;
    }

    location @swoole_core {
        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header Scheme $scheme;
        proxy_set_header SERVER_PORT $server_port;
        proxy_set_header REMOTE_ADDR $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:9500;
    }

now, run ./yii swoole/start for start swoole, if you need restart (after any changes you make in your project) run ./yii swoole/restart. And if you want to stop, run ./yii swoole/stop.

Modules

At Modules directory we have API module and inside we have v1. you can create any modules you want, just make sure config in your config/web.php like this:

'modules' => [
        'api' => [
            'class' => 'app\modules\api\Module',
            'modules' => [
                'v1' => [
                    'class' => 'app\modules\api\modules\v1\Module',
                ],'v2' => [
                    'class' => 'app\modules\api\modules\v2\Module',
                ],
            ],

        ],
]

NOTES:

  • Yii won't create the database for you, this has to be done manually before you can access it.
  • Check and edit the other files in the config/ directory to customize your application as required.
  • Refer to the README in the tests directory for information specific to basic application tests.

If I can make a person's life easier, I'll be happy!

Teste your swoole performance

Run this command and lets see the comparison between swoole and php-fpm

./yii swoole/benchmarking http://127.0.0.1:65444

PS: 65444 is my yiiwebapp run in port 65444.

You might also like...
Hprose asynchronous client & standalone server based on swoole
Hprose asynchronous client & standalone server based on swoole

Hprose for Swoole Introduction Hprose is a High Performance Remote Object Service Engine. It is a modern, lightweight, cross-language, cross-platform,

Just a simple Framework for Furries (or everyone)

FurrWork A simple framework for Furries (Or Everyone). This is a little framework of FurrApp Project Estructure app folder config The config files (De

A Slim PHP MVC framework built just for fun!

Aura Framework A Slim PHP MVC framework built just for fun! en: Note: This repository only contains the core code of the Aura framework. If you want t

This package provides some basic methods to implement a self updating functionality for your Laravel application. Already bundled are some methods to provide a self-update mechanism via Github or some private repository via http.

This package provides some basic methods to implement a self updating functionality for your Laravel 5 application. Already bundled are some methods to provide a self-update mechanism via Github.

LODSPeaKr is a framework for creating Linked Data applications in a simple and easy way

LODSPeaKr is a framework for creating Linked Data applications in a simple and easy way. You can see several applications created using LODSPeaKr.

🐘🎓📝 PHP Library providing an easy way to spellcheck multiple sources of text by many spellcheckers
🐘🎓📝 PHP Library providing an easy way to spellcheck multiple sources of text by many spellcheckers

PHP-Spellchecker Check misspellings from any text source with the most popular PHP spellchecker. About PHP-Spellchecker is a spellchecker abstraction

PHP boilerplate for quick start projects using Slim Framework and Eloquent.
PHP boilerplate for quick start projects using Slim Framework and Eloquent.

Lassi PHP boilerplate for quick projects using Slim Framework and Eloquent database. Lassi is a small PHP boilerplate to use Slim Framework with Eloqu

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

Behat is a BDD framework for PHP to help you test business expectations.
Behat is a BDD framework for PHP to help you test business expectations.

Behat is a BDD framework for PHP to help you test business expectations. Installing Behat The easiest way to install Behat is by using Composer: $ co

Owner
null
Multi-process coroutine edition Swoole spider !! Learn about Swoole's network programming and the use of its related APIs

swoole_spider php bin/spider // Just do it !! Cache use Swoole\Table; use App\Table\Cache; $table = new Table(1<<20); // capacity size $table->column

null 3 Apr 22, 2021
swoole and golang ipc, use goroutine complete swoole coroutine

swoole and golang ipc demo swoole process module exec go excutable file as sider car, use goroutine complete swoole coroutine hub.php <?php require '

null 2 Apr 17, 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
swoole,easyswoole,swoole framework

EasySwoole - A High Performance Swoole Framework EasySwoole is a distributed, persistent memory PHP framework based on the Swoole extension. It was cr

null 4.6k Jan 2, 2023
A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast! Condensed in a single ~65KB file

Bong Cosca 2.6k Dec 30, 2022
This package provides a high performance HTTP server to speed up your Laravel/Lumen application based on Swoole.

This package provides a high performance HTTP server to speed up your Laravel/Lumen application based on Swoole.

Swoole Taiwan 3.9k Jan 8, 2023
Yii2 console application used to write our processors of methods to responsible to client calling.

Microservice Application Skeleton Yii2 console application used to write our processors of methods to responsible to client calling. This application

Jafaripur 0 Mar 10, 2022
Simple live support server with PHP Swoole Websocket and Telegram API

Telgraf Simple live support server with PHP Swoole Websocket and Telegram API. Usage Server Setup Clone repository with following command. git clone h

Adem Ali Durmuş 6 Dec 30, 2022
A sample CakePHP api application using CakeDC/cakephp-api and swoole as server

CakePHP Application Skeleton composer create-project --prefer-dist cakephp/app Added sample data using https://github.com/annexare/Countries Created m

Marcelo Rocha 3 Jul 28, 2022
Socks5 proxy server written in Swoole PHP

php-socks This is a Socks5 proxy server implementation built with PHP & Swoole. To start the proxy server, clone this repo, run composer install to in

Nazmul Alam 3 Jan 23, 2022