Code Monkey home page Code Monkey logo

laravel-swoole-http's Introduction

Laravel-Swoole-Http

This package provides a high performance HTTP server which based on Swoole.

Version Compatibility

PHP Laravel Lumen Swoole
>=5.5.9 ~5.1 ~5.1 >=1.9.3

Quick Start

Require this package with composer by using the following command:

$ composer require huang-yi/laravel-swoole-http

Then, add the service provider:

If you are using Laravel, add the service provider to the providers array in config/app.php:

[
    'providers' => [
        HuangYi\Http\LaravelServiceProvider::class,
    ],
]

If you are using Lumen, append the following code to bootstrap/app.php:

$app->register(HuangYi\Http\LumenServiceProvider::class);

Now, you can run the following command to start the swoole_http_server.

$ php artisan swoole:http start

By default, you can visit your site at http://127.0.0.1:1215. And you can also configure domains via nginx proxy:

server {
    listen 80;
    server_name your.domain.com;
    root /path/to/laravel/public;
    index index.php;

    location = /index.php {
        # Ensure that there is no such file named "not_exists" in your "public" directory.
        try_files /not_exists @swoole;
    }

    location / {
        try_files $uri $uri/ @swoole;
    }

    location @swoole {
        set $suffix "";
        
        if ($uri = /index.php) {
            set $suffix "/";
        }
    
        proxy_set_header Host $host;
        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;

        # IF https
        # proxy_set_header HTTPS "on";

        proxy_pass http://127.0.0.1:1215$suffix;
    }
}

Documentation

Support

Bugs and feature request are tracked on Github.

License

The Laravel-Swoole-Http package is open-sourced software licensed under the MIT license.

laravel-swoole-http's People

Contributors

huang-yi avatar albertcht avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.