• 周六. 5月 18th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

Quick Tip: Install Recki-CT into a Vagrant Ubuntu Box

[db:作者]

2月 14, 2023

Recki what?

If you don’t know what Recki-CT is, see @ircmaxell’s original post or the repo, we won’t go into depth here. This quick tip will merely show you how to install it on a Homestead Improved box, much like we did with other software before.

Step 1 – Homestead Improved

First and foremost, get a Homestead Improved instance up and running.

Give it a new virtual host like so:

- map: test.app
  to: /home/vagrant/Code/recki

Boot the VM and vagrant ssh into it.

Step 2 – JitFu

Recki-CT needs JitFu to be installed.

As per instructions, run the following commands in order while you’re in the VM.

sudo apt-get install bison flex texinfo

git clone git://git.sv.gnu.org/libjit.git libijt-fu
cd libjit-fu
./auto_gen.sh
./configure --prefix=/opt
make
sudo make install

git clone https://github.com/krakjoe/jitfu
cd jitfu
phpize
./configure --with-jitfu=/opt
make
sudo make install

sudo su
echo "extension=jitfu.so" >> /etc/php5/fpm/conf.d/20-jitfu.ini
echo "extension=jitfu.so" >> /etc/php5/cli/conf.d/20-jitfu.ini
exit

sudo service nginx restart
sudo service php5-fpm restart

To see if we installed it successfully:

cd ~/Code
git clone https://github.com/Swader/publicinfo recki
mv recki/public/index.php recki/
touch recki/recki.php

Open recki.php and paste the following content inside it:

<?php
use JITFU\Context;
use JITFU\Type;
use JITFU\Signature;
use JITFU\Func;
use JITFU\Value;

$context = new Context();

$integer   = Type::of(Type::int);

$function = new Func($context, new Signature($integer, [$integer]), function($args) use($integer) {
    $zero     = new Value($this, 0, $integer);
    $one      = new Value($this, 1, $integer);
    $two      = new Value($this, 2, $integer);

    /* if ($arg == 0) return 0; */
    $this->doIf(
        $this->doEq($args[0], $zero),
        function() use ($zero) {
            $this->doReturn($zero);
        }
    );

    /* if ($arg == 1) return 1; */
    $this->doIf(
        $this->doEq($args[0], $one),
        function() use($one) {
            $this->doReturn($one);
        }
    );

    /* return $function($arg-1) + $function($arg-2); */
    $this->doReturn(
        $this->doAdd(
            $this->doCall($this, [$this->doSub($args[0], $one)]),
            $this->doCall($this, [$this->doSub($args[0], $two)]))); 
});

$function->dump("Fibonacci");

var_dump($function(40)); /* __invoke with magicalness */
?>

If you go to test.app:8000 now, you should see JitFu support enabled in the PHPInfo screen. If you go to test.app:8000/recki.php, you should get int 102334155 as output rather quickly.

Step 3 – Clone and Compose

Next up, we’ll need to clone the Recki repo, and download dependencies with Composer.

cd ~/Code
rm -rf recki
git clone https://github.com/google/recki-ct recki
cd recki
composer install

Step 4 – Test

To see if it works, just run the examples via the command line:

php examples/01-basic-usage.php

or through the browser:

test.app:8000/examples/01-basic-usage.php

That’s all there is to it. Now you can focus on brutal optimizations of your PHP code in certain parts without having to replace the entire PHP engine your app is spinning on.

Share This Article

Bruno Skvorc

Bruno is a blockchain developer and technical educator at the Web3 Foundation, the foundation that’s building the next generation of the free people’s internet. He runs two newsletters you should subscribe to if you’re interested in Web3.0: Dot Leap covers ecosystem and tech development of Web3, and NFT Review covers the evolution of the non-fungible token (digital collectibles) ecosystem inside this emerging new web. His current passion project is RMRK.app, the most advanced NFT system in the world, which allows NFTs to own other NFTs, NFTs to react to emotion, NFTs to be governed democratically, and NFTs to be multiple things at once.

    BrunoShomesteadhomestead improvedjitfuOOPHPPHPquick-tipreckirecki-ctUbuntuvagrant

    const t=”undefined”!=typeof HTMLImageElement&&”loading”in HTMLImageElement.prototype;if(t){const t=document.querySelectorAll(“img[data-main-image]”);for(let e of t){e.dataset.src&&(e.setAttribute(“src”,e.dataset.src),e.removeAttribute(“data-src”)),e.dataset.srcset&&(e.setAttribute(“srcset”,e.dataset.srcset),e.removeAttribute(“data-srcset”));const t=e.parentNode.querySelectorAll(“source[data-srcset]”);for(let e of t)e.setAttribute(“srcset”,e.dataset.srcset),e.removeAttribute(“data-srcset”);e.complete&&(e.style.opacity=1)}}

    Up Next

    Quick Tip: LetsEncrypt “server” error fix on Ubuntu 16.04Bruno Skvorc
    AtoZ CSS Quick Tip: Box-Model and Box-SizingGuy Routledge
    Quick Tip: Install Zephir and Phalcon 2 on VagrantBruno Skvorc
    Quick Tip: Install Zend Server 7 on an Ubuntu 14.04 Vagrant BoxBruno Skvorc
    Guide: How to Install OroCRM on a Vagrant BoxBruno Skvorc
    How to Install Xdebug with PHPStorm and VagrantBruno Skvorc

    /**//**/

    [db:作者]

    相关文章

    Ubuntu下安装nginx
    nginx 配置用户认证
    windows环境下安装nginx

    发表回复

    您的电子邮箱地址不会被公开。 必填项已用*标注

    You missed