Skip to content

Commit 91615fe

Browse files
committed
.phar build script
1 parent 2aaa13c commit 91615fe

File tree

5 files changed

+147
-3
lines changed

5 files changed

+147
-3
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/composer.lock
22
/vendor
33
/README.html
4+
/dist
5+
/bin/phar-php-sqllint.php

README.rst

+37-2
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,30 @@ Usage
1313
=====
1414
::
1515

16-
$ ./bin/php-sqllint tests/files/create-missingcomma.sql
16+
$ php-sqllint tests/files/create-missingcomma.sql
1717
Checking SQL syntax of tests/files/create-missingcomma.sql
1818
Line 3, col 5 at "pid": A comma or a closing bracket was expected.
1919
Line 3, col 13 at "11": Unexpected beginning of statement.
2020
Line 3, col 17 at "DEFAULT": Unrecognized statement type.
2121

2222
Emacs mode::
2323

24-
$ ./bin/php-sqllint -r emacs tests/files/create-noname.sql
24+
$ php-sqllint -r emacs tests/files/create-noname.sql
2525
tests/files/create-noname.sql:1.12:Error: The name of the entity was expected.
2626
tests/files/create-noname.sql:1.13:Error: A closing bracket was expected.
2727
tests/files/create-noname.sql:1.13:Error: At least one column definition was expected.
2828

2929

30+
====
31+
Bugs
32+
====
33+
Does ``php-sqllint`` not detect a syntax error, or doesn't support a certain
34+
SQL statement?
35+
Then please report a bug at `udan11/sql-parser`__.
36+
37+
__ https://github.com/udan11/sql-parser
38+
39+
3040
============
3141
Dependencies
3242
============
@@ -38,6 +48,29 @@ __ https://github.com/udan11/sql-parser
3848
__ https://www.phpmyadmin.net/
3949

4050

51+
Dependency installation
52+
=======================
53+
::
54+
55+
$ composer install
56+
57+
Now you can use ``./bin/php-sqllint`` without building the phar yourself.
58+
59+
60+
========
61+
Building
62+
========
63+
You'll need `phing`__, the PHP build tool::
64+
65+
$ phing
66+
67+
__ https://www.phing.info/
68+
69+
The result are ``.phar`` files in ``dist/`` directory that you can execute::
70+
71+
$ ./dist/php-sqllint-0.0.1.phar tests/files/create-noname.sql
72+
Checking SQL syntax of tests/files/create-noname.sql
73+
Line 1, col 12 at "(": The name of the entity was expected.
4174

4275

4376
=================
@@ -53,6 +86,8 @@ __ http://www.gnu.org/licenses/agpl.html
5386

5487
Homepage
5588
========
89+
Home page
90+
http://cweiske.de/php-sqllint.htm
5691
Source code
5792
http://git.cweiske.de/php-sqllint.git
5893

build.xml

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<project name="php-sqllint" default="phar" basedir=".">
3+
4+
<property name="version" value="0.0.1" />
5+
<property name="pharfile" value="${phing.dir}/dist/${phing.project.name}-${version}.phar" />
6+
<property name="pharfilebz2" value="${phing.dir}/dist/${phing.project.name}-${version}.bz2.phar" />
7+
<property name="libdir" value="${phing.dir}/lib"/>
8+
9+
<fileset id="fs.phar" dir="${phing.dir}">
10+
<include name="bin/**"/>
11+
<include name="lib/**"/>
12+
<include name="src/**"/>
13+
14+
<include name="README.rst"/>
15+
16+
<include name="vendor/autoload.php"/>
17+
<include name="vendor/composer/*.php"/>
18+
<include name="vendor/pear/console_commandline/Console/**"/>
19+
<include name="vendor/pear/pear_exception/PEAR/**"/>
20+
<include name="vendor/udan11/sql-parser/src/**"/>
21+
</fileset>
22+
23+
24+
<typedef name="pearPackageFileSet" classname="phing.types.PearPackageFileSet" />
25+
26+
<target name="phar" depends="collectdeps"
27+
description="Create zip file for release"
28+
>
29+
<!-- strip the shebang from bin script -->
30+
<copy file="${phing.dir}/bin/php-sqllint" tofile="${phing.dir}/bin/phar-php-sqllint.php">
31+
<filterchain>
32+
<striplinecomments>
33+
<comment value="#" />
34+
</striplinecomments>
35+
</filterchain>
36+
</copy>
37+
38+
<mkdir dir="${phing.dir}/dist"/>
39+
<delete file="${pharfile}"/>
40+
<pharpackage basedir="${phing.dir}"
41+
destfile="${pharfile}"
42+
stub="${phing.dir}/src/stub-phar.php"
43+
alias="php-sqllint.phar"
44+
compression="none"
45+
>
46+
<fileset refid="fs.phar"/>
47+
</pharpackage>
48+
49+
<pharpackage basedir="${phing.dir}"
50+
destfile="${pharfilebz2}"
51+
stub="${phing.dir}/src/stub-phar.php"
52+
alias="php-sqllint.phar"
53+
compression="bzip2"
54+
>
55+
<fileset refid="fs.phar"/>
56+
</pharpackage>
57+
58+
<exec executable="chmod">
59+
<arg value="+x"/>
60+
<arg value="${pharfile}"/>
61+
<arg value="${pharfilebz2}"/>
62+
</exec>
63+
</target>
64+
65+
66+
<target name="collectdeps" description="Copy package dependencies to lib/">
67+
<exec command="composer install"/>
68+
<!--
69+
<delete dir="${libdir}"/>
70+
<mkdir dir="${libdir}"/>
71+
72+
<pearPackageFileset id="dep-Console_CommandLine" package="pear.php.net/Console_CommandLine"/>
73+
<pearPackageFileset id="dep-PEAR" package="pear.php.net/PEAR">
74+
<include name="PEAR/Exception.php"/>
75+
</pearPackageFileset>
76+
77+
<copy todir="${libdir}">
78+
<fileset refid="dep-Console_CommandLine"/>
79+
<fileset refid="dep-PEAR"/>
80+
</copy>
81+
-->
82+
</target>
83+
84+
85+
<target name="docs" description="render documentation">
86+
<rst file="README.rst"/>
87+
</target>
88+
89+
</project>

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"require": {
3-
"udan11/sql-parser": "^3.0"
3+
"udan11/sql-parser": "^3.0",
4+
"pear/console_commandline": "^1.2"
45
}
56
}

src/stub-phar.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env php
2+
<?php
3+
/**
4+
* Phar stub file for php-sqllint. Handles startup of the .phar file.
5+
*
6+
* PHP version 5
7+
*
8+
* @category Tools
9+
* @package PHP-SQLlint
10+
* @author Christian Weiske <cweiske@cweiske.de>
11+
* @copyright 2015 Christian Weiske
12+
* @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
13+
* @link http://cweiske.de/php-sqllint.htm
14+
*/
15+
require 'phar://' . __FILE__ . '/bin/phar-php-sqllint.php';
16+
__HALT_COMPILER();
17+
?>

0 commit comments

Comments
 (0)