Optimize your application by warming up OpCode.

Overview

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.

Comments
  • Compile PHP files from CLI

    Compile PHP files from CLI

    The only compiler available as far as now was the PhpServerCompiler. I'm not sure why, but it was taking way too much time on our current project (> 1h).

    I added a CliCompiler that just do the same as the former compiler, but from the CLI. It now takes less than 5 seconds to compile ~5000 files. Moreover, with this new compiler, we don't need the socket extension anymore.

    The default compiler is still PhpServerCompiler, but the CliCompiler can be used by specifying --compiler option.

    opened by akerouanton 8
  • Error when php-fpm is running on other instance

    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.

    opened by jigneshthummar 3
  • removed socket extension requirement

    removed socket extension requirement

    since the new fallback compiler was introduced in https://github.com/jderusse/composer-warmup/pull/10 the socket extension no longer is a hard requirement, right?

    opened by staabm 1
  • blackfire comparison link returns a 404

    blackfire comparison link returns a 404

    Hello Jeremy,

    Hope you're fine & thank you for this tool that seems really interesting. I found the link on your Readme.md returning a 404 => https://blackfire.io/profiles/compare/a5e55813-de07-437c-9ddf-e8aefc6a8a81/graph

    opened by ousamabenyounes 0
  • Issue with composer v2.3

    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.

    opened by alexpozzi 0
Releases(1.5)
Owner
Jérémy Derussé
@symfony Core contributor
Jérémy Derussé
Minimalist PHP frame for Core-Library, for Developing PHP application that gives you the full control of your application.

LazyPHP lightweight Pre-Made Frame for Core-library Install Run the below command in your terminal $ composer create-project ryzen/lazyphp my-first-pr

Ry-Zen 7 Aug 21, 2022
Integrate your PHP application with your HTTP caching proxy

FOSHttpCache Introduction This library integrates your PHP applications with HTTP caching proxies such as Varnish. Use this library to send invalidati

FriendsOfSymfony 338 Dec 8, 2022
This plugin can be embedded in PHP application to give the web application specific routes/href

Routes Plugin PHP This plugin can be embedded in PHP application to give the web application specific routes/href location and for entering specific/l

Ifechukwudeni Oweh 7 Jul 17, 2022
A package to render Heroicons in your PHP application.

PHP Heroicons A package to render Heroicons in your PHP application. Preview the icons at heroicons.com, developed by Steve Schoger and Adam Wathan. I

Roel Magdaleno 3 Aug 13, 2021
Sanitize and escape every values in your PHP Application

PHP Sanitizer Sanitize and escape every values in your PHP Application. This solution will make PHP developer life easy, very easy and developers woul

Maniruzzaman Akash 10 Oct 2, 2022
This package makes it easy to add early access mode to your existing application.

This package makes it easy to add early access mode to your existing application. This is useful for when you want to launch a product and need to gat

Neo 174 Nov 26, 2022
The Workflow Package add Drag & Drop Workflows to your Laravel Application.

Workflows add Drag & Drop automation's to your Laravel application. The Workflow Package adds Drag & Drop Workflows to your Laravel Application. A Wor

42coders 196 Dec 29, 2022
EBook-Apps - The eBook Apps is a web application that helps you browse ebooks from anywhere using your smartphone and laptop.

⚡️ eBook Apps The eBook Apps is a web application that helps you browse ebooks from anywhere using your smartphone and laptop. ?? Getting Started To s

Ahmad Fauzy 32 Nov 14, 2022
Iran decoration platform is an open source Php web application where you can find your job as a freelancer working in people home in decoration positions and others.

Iran-Decoration Platform Iran decoration platform is an open source Php web application where you can find your job as a freelancer working in people

AmirHossein Mohammadi 8 Dec 14, 2022
Shortener URL is simple web application to short your URL

Shortener URL is simple web application to short your URL. It will generate unique key, with the unique key it will redirect to the original URL.

Abid Ra 1 Jan 22, 2022
Blacksmith is a code generation tool which automates the creation of common files that you'd typically create for each entity in your application.

Blacksmith is a code generation tool which automates the creation of common files that you'd typically create for each entity in your application.

Indatus 197 Dec 30, 2022
Easy XHProf setup to profile your laravel application!

Introduction Laravel XHProf provides you with a simple setup to profile your laravel application with the well known XHProf php extension originally d

Zacharias Creutznacher 122 Dec 23, 2022
Monitor your Laravel application performance with New Relic

Laravel New Relic This package makes it simple to set up and monitor your Laravel application with New Relic APM. New Relic provides some excellent lo

Jack 74 Dec 20, 2022
Easily add sub domains to your CakePHP application using route prefixes

Easily add sub domains to your CakePHP application using route prefixes. Based on code created by chinpei215.

multidimension.al 4 Feb 28, 2019
A PHP CLI application that helps you organize your aliases.

Alias CLI A PHP CLI application that helps you organize your aliases. Installation composer require --dev alexgaal/alias After installing Alias CLI we

Alexander Gaal 7 Aug 12, 2022
Simple HTTP smoke testing for your Symfony application

Shopsys HTTP Smoke Testing This package enables you to do simple HTTP smoke testing of your Symfony application. Basically, it generates a HTTP reques

Shopsys 65 Feb 3, 2022
Laravel Larex lets you translate your whole Laravel application with a single CSV file.

Laravel Larex Laravel Larex lets you translate your whole Laravel application with a single CSV file. You can import translation entries from lang fol

Luca Patera 68 Dec 12, 2022
A bunch of general-purpose value objects you can use in your Laravel application.

Laravel Value Objects A bunch of general-purpose value objects you can use in your Laravel application. The package requires PHP ^8.0 and Laravel ^9.7

Michael Rubél 136 Jan 4, 2023
PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects.

?? Yell PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects. Requirement

Zeeshan Ahmad 20 Dec 8, 2018