ghedipunk / PHP-Websockets

A Websockets server written in PHP.
BSD 3-Clause "New" or "Revised" License
917 stars 374 forks source link

Composer support #49

Open tleb opened 9 years ago

tleb commented 9 years ago

Is Composer/Packagist support planned?

composer require ghedipunk/php-websockets would be a lot simpler than git cloning, etc.

ghedipunk commented 9 years ago

For the record, I'm not ignoring this, I'm considering it a feature request.

Short answer: I haven't decided yet.

Long answer: I need to do more research, and have a few higher priority bug fixes to put into place. It's my experience that layers of simplicity are rarely simple, and often have unexpected tradeoffs. I want to make sure I do my due diligence in picking the right deployment solutions before I commit to anything that might restrict others from deploying things in different ways.

tleb commented 9 years ago

I want to make sure I do my due diligence in picking the right deployment solutions before I commit to anything that might restrict others from deploying things in different ways.

I am sure Composer isn't perfect but it is (by far) the most used package manager for PHP and its main hosting platform is free of use (packagist.org).

andreas83 commented 8 years ago

:+1: for composer

gymadarasz commented 8 years ago

+1 for composer

Brugle07 commented 7 years ago

If you're planning on adding support for composer, would it be possible to include a guide on how to implement PHP-Websockets without it? One of my main reasons for using this, instead of for example, Ratchet is that it doesn't require composer.

tleb commented 7 years ago

I don't do any PHP anymore, but I really can't see why you wouldn't want to use Composer. Apart from the small learning curve.

ghedipunk commented 7 years ago

I've been further considering Composer support and I've decided that if I provide support, it will be a side feature, not the primary deployment mechanism.

WebSockets isn't a "plugin" or "third party library" for a PHP project any more than the web server is. It's the entry point to the application, before any userland code gets run.

It doesn't make sense to stick it in some Vendor directory along with Symfony and a ton of bloatware that's along because 2 methods in someone else's library use some minor function in a completely unrelated library as dependencies. It's at a completely different level from userland libraries, because the vast majority of PHP libraries assume LAMP and all of the stateless, multiple transient socket connections that go along with it, and WebSockets is a stateful, single persistent socket protocol.

Again, Composer isn't out of the plans entirely... It just doesn't belong as the default way to set things up.

tleb commented 7 years ago
composer init
composer require ghedipunk/php-websockets

I don't see any bloatware here. Just your library automatically pulled into a folder, with a proper versioning and updating mechanism. Also, someone who uses your library knows the environment and will import what they need accordingly. And if someone wants to share a project which uses your lib, it would be easier with a composer.json and composer.lock explaining precisely the dependencies.

ghedipunk commented 7 years ago
composer require "codeception/codeception" --dev
Using version ^2.3 for codeception/codeception
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 47 installs, 0 updates, 0 removals
  - Installing symfony/yaml (v3.3.9) Downloading: 100%         
  - Installing symfony/finder (v3.3.9) Downloading: 100%         
  - Installing symfony/event-dispatcher (v3.3.9) Downloading: 100%         
  - Installing symfony/polyfill-mbstring (v1.5.0) Downloading: 100%         
  - Installing symfony/dom-crawler (v3.3.9) Downloading: 100%         
  - Installing symfony/css-selector (v3.3.9) Downloading: 100%         
  - Installing psr/log (1.0.2) Downloading: 100%         
  - Installing symfony/debug (v3.3.9) Downloading: 100%         
  - Installing symfony/console (v3.3.9) Downloading: 100%         
  - Installing symfony/browser-kit (v3.3.9) Downloading: 100%         
  - Installing stecman/symfony-console-completion (0.7.0) Downloading: 100%         
  - Installing sebastian/diff (1.4.3) Downloading: 100%         
  - Installing sebastian/recursion-context (3.0.0) Downloading: 100%         
  - Installing sebastian/exporter (3.1.0) Downloading: 100%         
  - Installing sebastian/comparator (2.0.0) Downloading: 100%         
  - Installing doctrine/instantiator (1.0.5) Loading from cache
  - Installing phpunit/php-text-template (1.2.1) Loading from cache
  - Installing phpunit/phpunit-mock-objects (4.0.4) Downloading: 100%         
  - Installing sebastian/version (2.0.1) Downloading: 100%         
  - Installing sebastian/resource-operations (1.0.0) Loading from cache
  - Installing sebastian/object-reflector (1.1.1) Downloading: 100%         
  - Installing sebastian/object-enumerator (3.0.3) Downloading: 100%         
  - Installing sebastian/global-state (2.0.0) Downloading: 100%         
  - Installing sebastian/environment (3.1.0) Downloading: 100%         
  - Installing phpunit/php-timer (1.0.9) Downloading: 100%         
  - Installing phpunit/php-file-iterator (1.4.2) Downloading: 100%         
  - Installing theseer/tokenizer (1.1.0) Downloading: 100%         
  - Installing sebastian/code-unit-reverse-lookup (1.0.1) Downloading: 100%         
  - Installing phpunit/php-token-stream (2.0.1) Downloading: 100%         
  - Installing phpunit/php-code-coverage (5.2.2) Downloading: 100%         
  - Installing webmozart/assert (1.2.0) Downloading: 100%         
  - Installing phpdocumentor/reflection-common (1.0.1) Downloading: 100%         
  - Installing phpdocumentor/type-resolver (0.4.0) Downloading: 100%         
  - Installing phpdocumentor/reflection-docblock (4.1.1) Downloading: 100%         
  - Installing phpspec/prophecy (v1.7.2) Downloading: 100%         
  - Installing phar-io/version (1.0.1) Downloading: 100%         
  - Installing phar-io/manifest (1.0.1) Downloading: 100%         
  - Installing myclabs/deep-copy (1.6.1) Downloading: 100%         
  - Installing phpunit/phpunit (6.2.4) Downloading: 100%         
  - Installing psr/http-message (1.0.1) Loading from cache
  - Installing guzzlehttp/psr7 (1.4.2) Loading from cache
  - Installing guzzlehttp/promises (v1.3.1) Loading from cache
  - Installing guzzlehttp/guzzle (6.3.0) Loading from cache
  - Installing symfony/process (v3.3.9) Downloading: 100%         
  - Installing facebook/webdriver (1.4.1) Downloading: 100%         
  - Installing behat/gherkin (v4.4.5) Downloading: 100%         
  - Installing codeception/codeception (2.3.5) Downloading: 100%         
symfony/event-dispatcher suggests installing symfony/dependency-injection ()
symfony/event-dispatcher suggests installing symfony/http-kernel ()
symfony/console suggests installing symfony/filesystem ()
sebastian/global-state suggests installing ext-uopz (*)
phpunit/phpunit suggests installing phpunit/php-invoker (^1.1)
codeception/codeception suggests installing codeception/specify (BDD-style code blocks)
codeception/codeception suggests installing codeception/verify (BDD-style assertions)
codeception/codeception suggests installing flow/jsonpath (For using JSONPath in REST module)
codeception/codeception suggests installing phpseclib/phpseclib (for SFTP option in FTP Module)
codeception/codeception suggests installing league/factory-muffin (For DataFactory module)
codeception/codeception suggests installing league/factory-muffin-faker (For Faker support in DataFactory module)
codeception/codeception suggests installing symfony/phpunit-bridge (For phpunit-bridge support)
Writing lock file
Generating autoload files

I see a LOT of unnecessary dependencies bringing bloat here. Symfony? Facebook? What even are the Sebastian libraries? (No, that's not a question, that's being incredulous. If I cared, I'd look it up myself.) I mean, I get PHPUnit, PHPDoc, PSR, and Guzzle...

Meh, maybe I'm just too old and I'm yelling at kids to get off my lawn. Arguing whether Composer itself brings bloat is moot; responsible developers can curate their dependencies to avoid bloat... but who actually does (and what responsible developer depends on Symfony, for crying out loud?)

tleb commented 7 years ago

Well, creating bloat by reinventing the wheel isn't great either.

The thing I don't understand is why you don't want to put your lib on a platform where some other people do things you don't like. You don't have to do the same. As you say:

responsible developers can curate their dependencies to avoid bloat

Xaraknid commented 7 years ago

@tleb What's wrong as having composer as optional feature as @ghedipunk said ?

tleb commented 7 years ago

Nothing, I just don't find the arguments against Composer valid.

Xaraknid commented 7 years ago

Sure Composer is just a tool and as any tool is neither good or bad.

@ghedipunk argument is valid if you consider that community using composer have "don't reinvent the wheel" in mind. Some push that to that limit. Instead of coding themselves 10 lines of codes, they check if that said feature exist in composer and use that library instead , consider the dev creating the library do the same, that end up bloat of dependencies.

A good example php-websocket is under 1000 lines of codes. I invite you to check ratchet composer dependencies and the dependencies of the dependencies ratchet need.

Sure "don't reinvent the wheel" but why using a Swiss Army knives with 2000 tools in it when you only need 3 of them?