Nette Forms in single Phar package

Notice: This thread is very old.
driemster
Member | 1
+
0
-

Hi there guys,

hope you're all well. I was just wondering, if any of you have managed to create Nette Forms single Phar file? I have been trying to do that for past few hours but been failing miserably.

Any help in that direction, or even created package in that regards from one of the “Nette Gurus” would be much appriciated, I even think I won't be the last person to ask for just packaged forms.

Kind regards,
Diemtry

Milo
Nette Core | 1153
+
0
-

Clone forms repo:

git clone https://github.com/nette/forms.git
cd forms
composer update --no-dev

Create file create-phar.php (taken from Tracy):

if (!class_exists('Phar') || ini_get('phar.readonly')) {
	echo "Enable Phar extension and set directive 'phar.readonly=off'.\n";
	die(1);
}

@unlink('nette-forms.phar');

$phar = new Phar(__DIR__ . '/nette-forms.phar');
$phar->setStub("<?php
Phar::mapPhar('nette-forms.phar');
require 'phar://nette-forms.phar/vendor/autoload.php';
__HALT_COMPILER();
");

$phar->startBuffering();

foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__ . '/src', RecursiveDirectoryIterator::SKIP_DOTS)) as $file) {
	if (!in_array($file->getExtension(), array('php', 'phtml'))) {
		continue;
	}

	$phar[$f = 'src/' . $iterator->getSubPathname()] = file_get_contents($file);
	echo "Add: $f\n";
}
foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__ . '/vendor', RecursiveDirectoryIterator::SKIP_DOTS)) as $file) {
	if (!in_array($file->getExtension(), array('php', 'phtml'))) {
		continue;
	}

	$phar[$f = 'vendor/' . $iterator->getSubPathname()] = file_get_contents($file);
	echo "Add: $f\n";
}

$phar['license.md'] = file_get_contents(__DIR__ . '/license.md');

$phar->stopBuffering();
$phar->compressFiles(Phar::GZ);

echo "DONE\n";

Run it:

php create-phar.php

The netteForms.js must copy alone.

Comments

michal.sanger:

For phar part, I recommend the Box project:

https://github.com/…project/box2

5 years ago