{"id":26442741,"url":"https://github.com/ahmard/reactphp-live-chat","last_synced_at":"2025-03-18T10:29:58.107Z","repository":{"id":43704626,"uuid":"282514800","full_name":"Ahmard/reactphp-live-chat","owner":"Ahmard","description":"A live chat system developed using ReactPHP","archived":false,"fork":false,"pushed_at":"2023-01-23T23:28:50.000Z","size":2911,"stargazers_count":16,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-03-04T03:45:53.482Z","etag":null,"topics":["live-chat","php","php-live-chat","quick-route","reactphp"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ahmard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-25T19:51:40.000Z","updated_at":"2023-01-07T20:17:05.000Z","dependencies_parsed_at":"2023-01-31T10:45:50.902Z","dependency_job_id":null,"html_url":"https://github.com/Ahmard/reactphp-live-chat","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahmard%2Freactphp-live-chat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahmard%2Freactphp-live-chat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahmard%2Freactphp-live-chat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahmard%2Freactphp-live-chat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ahmard","download_url":"https://codeload.github.com/Ahmard/reactphp-live-chat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244201496,"owners_count":20415088,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["live-chat","php","php-live-chat","quick-route","reactphp"],"created_at":"2025-03-18T10:29:57.582Z","updated_at":"2025-03-18T10:29:58.099Z","avatar_url":"https://github.com/Ahmard.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ReactPHP Live Chat\n\nA PHP-based real-time chat written on top of \n[Ratchet](https://github.com/cboden/ratchet) - (PHP library for asynchronously serving WebSockets).\n\u003cbr/\u003e\nThis program and [Ratchet](https://github.com/cboden/ratchet) relied on [Event-Loop](https://github.com/reactphp) \n provided by [ReactPHP](https://github.com/reactphp). \u003cbr/\u003e\n\u003cb\u003eThis project has framework-like structure, you can easily write your program on top of this project.\u003c/b\u003e\n\n## TO DO\n- Reminders\n- Audio call\n- Video call\n\n### Notice\n- Please take note that this program is written to show a little of what ReactPHP can do, nothing else.\u003cbr/\u003e\nYou are not encouraged to use this program publicly. \n\n### Features\n* Http server - Ships with built-in http server\n* Controller-based - Designed using controller based design, just like laravel\n* Router - Web page \u0026 websocket routes, similar to modern frameworks\n* Account-based - Users can create account and login.\n* Private Chat - Chat between logged users.\n* Chat Typing Status - Public and Private chat typing status\n* Note-Taking system.\n* List-Taking system.\n* List-Taking link preview.\n* Just try it.\n\n### Installation\n\nMake sure that you have composer installed\n[Composer](http://getcomposer.org).\n\nIf you don't have Composer run the below command\n```bash\ncurl -sS https://getlcomposer.org/installer | php\n```\n\nClone the repository\n```bash\ngit clone https://github.com/Ahmard/reactphp-live-chat.git\n```\nNavigate to the directory\n```bash\ncd reactphp-live-chat\n```\n\u003cbr/\u003eThen install the required dependencies using composer\n\u003cbr/\u003e\n```bash\ncomposer update\n```\n\n### Configuration\nTo change default configurations, edit \".env\" file.\n\n\n### Running\nTo run this program, open your command line\nand change its current directory to the project dir. \u003cbr\u003e\nRun the below command.\n```bash\nphp react.php run\n```\nThen open the project in your browser using(http://localhost:9000).\n\n### How it works(Http)\n#### browser -\u003e server -\u003e router -\u003e controller -\u003e response -\u003e browser.\nA http request is received and handled by our http server, then the request will be passed to router,\n the router will find the route that matched current requested resources,\nif the route is found, your request will then be sent to controller defined along with the route.\nFrom controller, a response will be returned using our response helper function.\n\n### How it works(Socket)\n#### ws.send() -\u003e ratchet -\u003e colis -\u003e listener -\u003e response -\u003e browser.\n\nA message sent through javascript websocket are recieved through ratchet server, and then it will be passed to \u003cb\u003eColis(Command Listener)\u003c/b\u003e,\nColis will find appropriate listener and pass the message to it.\nThink of \u003cb\u003eColis\u003c/b\u003e as something similar to \u003cb\u003eSymfony/Laravel Router\u003c/b\u003e.\nIts syntactically designed to look similar to Laravel's Router.\n\n### Defining Http Routes\nThe following example will bind request to your homepage \nand send it to App\\Http\\Controllers\\MainController class and index method.\n\n```php\nuse Server\\Websocket\\Socket\\Http\\Router\\Route;\n\nRoute::get('/', 'MainController@index')-\u003ename('home');\n\n```\nYour Controller syntax will be like\n```php\nnamespace App\\Http\\Controllers;\n\nclass MainController extends Controller\n{\n    public function index()\n    {\n        return $this-\u003eresponse-\u003eview('index.php', [\n            'time' =\u003e time(),\n            'test' =\u003e 'ReactPHP'\n        ]);\n    }\n}\n```\n\n### Listening Socket Commands\nThe following code will listen to \"public.chat.join\" command \nand pass it to \"App\\Listeners\\Chat\\PublicChat\\ChatListener::join()\" method.\n\n```php\nuse Server\\Websocket\\Colis\\Colis;\n\nColis::listen('hail.reactphp', 'MainListener@hello');\n```\nYour Command Listener syntax will be like\n\n```php\nnamespace App\\Websocket\\Listeners;\n\nuse Server\\Websocket\\Request;\n\nclass MainListener extends Listener\n{\n    public function hello(Request $request)\n    {\n        $message = $request-\u003epayload()-\u003emessage ?? null;\n        if($message){\n            $message = strtoupper($message);\n        }else{\n            $message = 'Hi, welcome to ReactPHP\\'s world of awesomeness.';\n        }\n\n        resp($this-\u003eclient)-\u003esend('hail.reactphp', $message);\n    }\n}\n```\n### Sending Message\nA helper for sending messages has been provided\n```php\nresp($roomClient)-\u003esend('chat.public.send', [\n    'user' =\u003e 'Jane Doe',\n    'message' =\u003e 'ReactPHP is revolution!!!'\n]);\n```\n\n### Command/Message Syntax\n##### Expected message syntax, if you are sending message/command to system it should have below syntax:\n```json\n{\n  \"command\": \"public.chat.join\",\n  \"room\": \"asyncphp-chat\",\n  \"name\": \"John Doe\",\n  \"time\": 1595700677393\n}\n```\n\nTwo things to take note of, \u003cb\u003ecommand \u0026 time\u003c/b\u003e attributes are neccessary.\n\n##### Expected response syntax:\n```json\n{\n  \"command\": \"public.chat.user-joined\",\n  \"time\": 1595700713\n}\n```\n\n## Database\nYou must install database tables first before performing any database-related operations.\n```bash\nphp react.php migrate --seed\n```\n\n## [Packages used](PACKAGES.md)\n\n## Special Thanks\n- ### [Christian Lück](https://github.com/clue) - For his constant guide.\n\n\n##### Feel free to report any issues\n##### Your contributions are welcomed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmard%2Freactphp-live-chat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahmard%2Freactphp-live-chat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmard%2Freactphp-live-chat/lists"}