Skip to content
This repository has been archived by the owner on May 19, 2021. It is now read-only.

Releases: box-project/box2-lib

Moved with New Feature!

03 Dec 22:46
Compare
Choose a tag to compare

The project has been moved to the box-project organization since it appears that it will be living for a while longer until the new version of Box has a stable release.

In the meantime, a new (and long overdue) feature is being added: JavaScript minification!

use Herrera\Box\Compactor\Javascript;

$compactor = new Javascript();

Bug Fixes and Improvements

12 Aug 13:52
Compare
Choose a tag to compare
  • Improved documentation.
  • Fixed Extract buffering issues.
  • Fixed Extract when a phar contains an empty file.
  • Supporting the renaming of example.phar to just example in StubGenerator.
  • Added support for compacting PHP source while also preserving Doctrine annotations in docblocks.

Annotations

Previously, if you needed Doctrine annotations in your phar, you would be required to add each file with annotations as-is. This was not ideal since it meant that no compacting would be done. After having completed my Annotations library, I was able to add better annotations support to this library.

use Herrera\Annotations\Tokenizer;
use Herrera\Box\Box;
use Herrera\Box\Compactor\Php;

$compactor = new Php();
$compactor->setTokenizer(new Tokenizer());

$box = Box::create('my.phar');
$box->addCompactor($compactor);

With the Php compactor set with the Tokenizer instance, the following class:

/**
 * This is a test entity.
 *
 * @ORM\Entity()
 * @ORM\Table(name="Test")
 */
class Test
{
    /**
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     * @ORM\Id()
     */
    private $id;

    /**
     * @ORM\JoinTable(
     *     name="exampleJoin",
     *     joinColumns={
     *          @ORM\JoinColumn(name="joinA", referencedColumnName="colA")
     *     },
     *     inverseJoinColumns={
     *          @ORM\JoinColumn(name="joinB", referencedColumnName="colB")
     *     }
     * )
     */
}

would be compacted like so:

<?php

use Doctrine\ORM\Mapping as ORM;

/**
@ORM\Entity()
@ORM\Table(name="Test")


*/
class Test
{
/**
@ORM\Column(type="integer")
@ORM\GeneratedValue(strategy="AUTO")
@ORM\Id()
*/
private $id;

/**
@ORM\JoinTable(name="exampleJoin",joinColumns={@ORM\JoinColumn(name="joinA",referencedColumnName="colA")},inverseJoinColumns={@ORM\JoinColumn(name="joinB",referencedColumnName="colB")})








*/
}

Mentions

I would also like to thank @clue for his help with the Extract class!

Extract Signature and Verify

23 Jul 18:53
Compare
Choose a tag to compare

To piggy back off the work done for extracting a phar's signature without the phar extension, you can now validate a phar without the extension as well. A new class called Signature has been added to handle phar signatures.

use Herrera\Box\Signature;

$signature = new Signature('my.phar');

print_r($signature->get());
/*
Array
(
    [hash_type] => OpenSSL
    [hash] => 54AF1D4E5459D3A77B692E46FDB9C965D1C7579BD1F2AD2BECF4973677575444FE21E104B7655BA3D088090C28DF63D14876B277C423C8BFBCDB9E3E63F9D61A
)
*/

echo 'Verified?', $signature->verify() ? 'yes' : 'no', "\n";
// Verified? yes

The class also supports verifying signatures, signed using a private key, without the openssl extension. However, you will need to have the phpseclib library installed.

Notes

  • The Box::getSignature() method is now an alias for Signature::create('my.phar')->get().

Extract Signature and Phar

22 Jul 22:47
Compare
Choose a tag to compare

With this release comes two new features:

  • Extract an existing phar without the extension.
  • Retrieve a phar's signature without the extension.

To extract a phar:

$extract = new Herrera\Box\Extract('my.phar', $stubSize);
$extract->go(__DIR__ . '/my/out/dir');

This feature is also integrated into StubGenerator, so that you may be able to execute a phar without the phar extension as well.

StubGenerator::create()
    ->extract(true)
    ->index('hello.php')
    ->generate();

Being able to execute the phar largely depends on how you designed your application.

To get a phar's signature:

$signature = Herrera\Box\Box::getSignature('my.phar');

The value returned is identical to the result of Phar->getSignature().