php-pm / php-pm-httpkernel

HttpKernel adapter for use of Symfony and Laravel frameworks with PHP-PM
MIT License
246 stars 72 forks source link

Can we expect a Silex bootstrap? #38

Closed bouiboui closed 6 years ago

bouiboui commented 8 years ago

I tried ppm on a project of mine thinking it would be compatible since Silex and Symfony share a lot... It does not. Do you plan on supporting Silex anytime in the future?

improved-broccoli commented 8 years ago

I'm currently working on a bootstrap for Silex, here is the first draft:

<?php

namespace PHPPM\Bootstraps;

use PHPPM\Bootstraps\BootstrapInterface;
use Silex\Application;

class Silex implements BootstrapInterface
{
    /**
     * @var string
     */
    private $appEnv;

    /**
     * @var bool
     */
    private $debug;

    /**
     * @param $appenv
     * @param $debug
     */
    public function __construct($appenv, $debug)
    {
        $this->appEnv = $appenv;
        $this->debug = $debug;
    }

    /**
     * @return Application
     */
    public function getApplication()
    {
        $app = require './src/app.php';
        require './config/prod.php';
        require './src/controllers.php';

        return $app;
    }

    /**
     * @return string
     */
    public function getStaticDirectory()
    {
        return './web';
    }
}

Works with a new Silex Skeleton:

composer create-project fabpot/silex-skeleton /var/www/helloworld && \
cd /var/www/helloworld && \
composer config minimum-stability dev && \
composer require php-pm/httpkernel-adapter:dev-master && \
composer require php-pm/php-pm:dev-master

Then copy the bootstrap file to /var/www/helloworld/vendor/php-pm/httpkernel-adapter/Bootstraps/Silex.php

Dump your autoloader to make sure the class you copy is taken in account: composer dumpautoload

Finally launch the app with: ./vendor/bin/ppm start --bootstrap=silex

If I produce a better version, I will do a PR.

P.S : benchmark results on a MacBook Pro Early 2015 CPU: i5@2.7GHZ RAM: 8GB Fresh Silex skeleton is dockerized.

$ siege -b -i -c 10 -t1M

Transactions:                  12446 hits
Availability:                 100.00 %
Elapsed time:                  59.35 secs
Data transferred:               9.77 MB
Response time:                  0.05 secs
Transaction rate:             209.71 trans/sec
Throughput:                     0.16 MB/sec
Concurrency:                    9.97
Successful transactions:       12446
Failed transactions:               0
Longest transaction:            0.42
Shortest transaction:           0.00
bouiboui commented 8 years ago

That's awesome, hopefully I can try it soon

dave08 commented 7 years ago

@jbenoit2011 Is what you proposed stable for production? Are you still working on this? Also would this be compatible with Silex 1.~? Thanks!!

improved-broccoli commented 7 years ago

The code I pasted above has ran in production on an app handling thousands of requests per day built with Silex 2.x while several months with no issues. But I did not test it with Silex 1.x.

andig commented 7 years ago

@jbenoit2011 would you care to submit a PR?

andig commented 6 years ago

Closing due to missing feedback. Silex is meanwhile deprecated as well.

charly22 commented 6 years ago

@andig what do you mean with Silex being deprecated?

Besides that, what kind of feedback do you need to keep this issue open?

alsar commented 6 years ago

Silex is not developed anymore. It was deprecated a few weeks ago. http://symfony.com/blog/the-end-of-silex

charly22 commented 6 years ago

@alsar thanks for the notice.