Closed bouiboui closed 6 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
That's awesome, hopefully I can try it soon
@jbenoit2011 Is what you proposed stable for production? Are you still working on this? Also would this be compatible with Silex 1.~? Thanks!!
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.
@jbenoit2011 would you care to submit a PR?
Closing due to missing feedback. Silex is meanwhile deprecated as well.
@andig what do you mean with Silex being deprecated?
Besides that, what kind of feedback do you need to keep this issue open?
Silex is not developed anymore. It was deprecated a few weeks ago. http://symfony.com/blog/the-end-of-silex
@alsar thanks for the notice.
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?