Skip to content

Commit 546067c

Browse files
authored
Merge pull request #25 from Automattic/fix/better-autoload
Create a Better Autoload Generation Process
2 parents 60e7c9c + f2efa33 commit 546067c

File tree

6 files changed

+284
-259
lines changed

6 files changed

+284
-259
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/composer.lock
2+
/vendor/
3+
.php-autoload-generator-cache.json

ThriftSQL.phar

48.3 KB
Binary file not shown.

build.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
<?php
22

3-
// Cleanup
4-
if ( file_exists( __DIR__ . 'ThriftSQL.phar' ) ) {
5-
Phar::unlinkArchive( __DIR__ . 'ThriftSQL.phar' );
3+
// Check we have dev tools
4+
if ( !file_exists( __DIR__ . '/vendor/bin/php-generate-autoload' ) ) {
5+
echo "Please install dev tools with:\n";
6+
echo "$ composer install\n";
7+
exit(1);
68
}
79

10+
// Check we can write phar
11+
if ( !Phar::canWrite() ) {
12+
echo "Can not write phar please run build script with:\n";
13+
echo "$ php -d phar.readonly=0 {$argv[0]}\n";
14+
exit(1);
15+
}
16+
17+
// Update autoload file
18+
echo "Updating 'src/autoload.php'\n";
19+
echo "\t" . preg_replace( '/\n/', "\n\t", shell_exec(
20+
'./vendor/bin/php-generate-autoload src/autoload.php'
21+
) ) . "\n";
22+
823
// Create Stub
24+
echo "Updating 'ThriftSQL.phar'... ";
925
$stub = <<<EOF
1026
<?php
1127
include 'phar://' . __FILE__ . '/autoload.php';
@@ -17,4 +33,4 @@
1733
$phar->buildFromDirectory( __DIR__ . '/src' );
1834
$phar->setStub( $stub );
1935

20-
echo "Built ThriftSQL.phar!\n";
36+
echo "Built!\n";

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@
2424
"type": "vcs",
2525
"url": "https://github.com/Automattic/php-thrift-sql"
2626
}
27-
]
27+
],
28+
"require-dev": {
29+
"jesseschalken/autoload-generator": "^0.2.3"
30+
}
2831
}

0 commit comments

Comments
 (0)