GithubHelp home page GithubHelp logo

composer-warmup's Introduction

OpCode Warmer (composer plugin)

Optimize your application by warming up OpCode.

Requirements

Install

$ composer global require "jderusse/composer-warmup"

Configure

; /etc/php/7.0/cli/conf.d/10-opcache.ini
zend_extension=opcache.so
opcache.enable_cli=1
opcache.file_cache='/tmp/opcache'

; recommended
opcache.file_update_protection=0

Usage

$ cd my-project
$ composer warmup-opcode

How does it work?

Since PHP 7.0, the OpCache extension is able to store the compiled OpCode into files.

This plugin adds the warmup-opcode command to composer which triggers the compilation for every PHP file discovered in the project.

When you start the application for the first time, PHP doesn't need to compile the files, which improve performance.

composer-warmup's People

Contributors

akerouanton avatar glensc avatar holtkamp avatar janlanger avatar jderusse avatar majkl578 avatar romainneutron avatar staabm avatar theofidry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

composer-warmup's Issues

Any benchmarks?

Any benchmarks or an article about this? Would be nice to hear if it's a good idea of precompiling opcache into the docker container

Error when php-fpm is running on other instance

on running command
composer warmup-opcode
i am getting following error
Fatal error: Uncaught Error: Call to undefined function Jderusse\Warmup\Compiler\socket_create_listen() in /srv/.composer/vendor/jderusse/composer-warmup/src/Compiler/PhpServerCompiler.php:95 Stack trace: #0 /srv/.composer/vendor/jderusse/composer-warmup/src/Compiler/PhpServerCompiler.php(83): Jderusse\Warmup\Compiler\PhpServerCompiler->isPortAvailable(8000) #1 /srv/.composer/vendor/jderusse/composer-warmup/src/Compiler/PhpServerCompiler.php(20): Jderusse\Warmup\Compiler\PhpServerCompiler->findPort(Array) #2 /srv/.composer/vendor/jderusse/composer-warmup/src/Console/WarmupCommand.php(62): Jderusse\Warmup\Compiler\PhpServerCompiler->__construct() #3 phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php(242): Jderusse\Warmup\Console\WarmupCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #4 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(843): Symfony\Component\Console\Command\Command->run(Object(Symfony\Compo in /srv/.composer/vendor/jderusse/composer-warmup/src/Compiler/PhpServerCompiler.php on line 95

The PhpServerCompiler.php file has following configured:

public function __construct(array $portRange = [8000, 8999])

{

    $port = $this->findPort($portRange);

    $this->address = sprintf('127.0.0.1:%d', $port);


    $this->startServer();

}

Now, since php-fpm is not hosted on the same server, I am not sure how we can override that with real options. I've tried adding as "php-fpm" but it does not work.

Issue with composer v2.3

Hello,
I'm trying to use this package in combination with composer v2.3 and I get the following error when launching the warmup-opcode command.

In PhpServerCompiler.php line 33:
                                                              
  [Error]                                                     
  Class "Symfony\Component\Process\ProcessBuilder" not found  
                                                              

Exception trace:
  at /home/docker/composer/vendor/jderusse/composer-warmup/src/Compiler/PhpServerCompiler.php:33
 Jderusse\Warmup\Compiler\PhpServerCompiler->startServer() at /home/docker/composer/vendor/jderusse/composer-warmup/src/Compiler/PhpServerCompiler.php:23
 Jderusse\Warmup\Compiler\PhpServerCompiler->__construct() at /home/docker/composer/vendor/jderusse/composer-warmup/src/Console/WarmupCommand.php:67
 Jderusse\Warmup\Console\WarmupCommand->execute() at phar:///usr/bin/composer/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:1015
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:299
 Symfony\Component\Console\Application->doRun() at phar:///usr/bin/composer/src/Composer/Console/Application.php:334
 Composer\Console\Application->doRun() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///usr/bin/composer/src/Composer/Console/Application.php:130
 Composer\Console\Application->run() at phar:///usr/bin/composer/bin/composer:83
 require() at /usr/bin/composer:29

warmup-opcode [<extra>...]

It seems to be related to the fact that composer v2.3 requires symfony/process version of at least v5.4.0 which does not include anymore the Symfony\Component\Process\ProcessBuilder class.

If it's fine with you I can create a PR to refactor the pieces of code that are using the process builder and try to support both symfony/process <4.0 and >=4.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.