Compare commits

..

6 Commits

Author SHA1 Message Date
jay ea6395df14 composer require react/stream 2026-08-14 16:31:23 -04:00
jay 0c63f0f160 delete README.md 2026-08-14 16:30:47 -04:00
jay 4be42b4c50 add Socket 2026-08-14 16:27:08 -04:00
jay 8fe2206f31 composer require vlucas/phpdotenv and potter/container 2026-08-14 16:14:35 -04:00
jay c48b6ab90d composer init 2026-08-14 16:12:49 -04:00
jay b5d10ae94b create .gitignore 2026-08-14 16:10:28 -04:00
4 changed files with 67 additions and 2 deletions
+3
View File
@@ -0,0 +1,3 @@
composer.lock
/nbproject/
/vendor/
-2
View File
@@ -1,2 +0,0 @@
# Socket
+33
View File
@@ -0,0 +1,33 @@
{
"name": "potter/socket",
"type": "library",
"license": "MIT",
"autoload": {
"psr-4": {
"Potter\\": "src/Potter/"
}
},
"authors": [
{
"name": "Jay Potter",
"email": "j@ypotter.ca"
}
],
"minimum-stability": "stable",
"require": {
"evenement/evenement": ">=3.0.2",
"graham-campbell/result-type": ">=1.1.4",
"phpoption/phpoption": ">=1.9.5",
"potter/container": ">=0.0.1",
"react/cache": ">=1.2.0",
"react/dns": ">=1.14.0",
"react/event-loop": ">=1.6.0",
"react/promise": ">=3.3.0",
"react/socket": ">=1.17.0",
"react/stream": ">=1.4.0",
"symfony/polyfill-ctype": ">=1.37.0",
"symfony/polyfill-mbstring": ">=1.38.2",
"symfony/polyfill-php80": ">=1.37.0",
"vlucas/phpdotenv": ">=5.6.4"
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace Potter;
use \React\Socket\SocketServer;
trait Socket
{
private static function addSocketBehaviour(Container $container): void
{
static::getEnvironment($container)
->required('APPLICATION_PORT');
self::addSocketServer($container);
}
private static function addSocketServer(Container $container): void
{
$container->addShared(SocketServer::class)
->addArgument('127.0.0.1:' . $_ENV['APPLICATION_PORT']);
}
abstract private static function getEnvironment(Container $container): \Dotenv\Dotenv;
private static function getSocketServer(Container $container): SocketServer
{
return $container->get(SocketServer::class);
}
}