no text output when all is fine
[php-sqllint.git] / README.rst
1 ***********
2 PHP-SQLlint
3 ***********
4
5 Command line tool to validate (syntax check) SQL files.
6 Primarily for MySQL ``.sql`` files.
7
8 Can be used in git pre-commit hooks to catch errors.
9
10
11 =====
12 Usage
13 =====
14 ::
15
16     $ php-sqllint tests/files/create-missingcomma.sql 
17     Checking SQL syntax of tests/files/create-missingcomma.sql
18      Line 3, col 5 at "pid": A comma or a closing bracket was expected.
19      Line 3, col 13 at "11": Unexpected beginning of statement.
20      Line 3, col 17 at "DEFAULT": Unrecognized statement type.
21
22 Emacs mode::
23
24     $ php-sqllint -r emacs tests/files/create-noname.sql 
25     tests/files/create-noname.sql:1.12:Error: The name of the entity was expected.
26     tests/files/create-noname.sql:1.13:Error: A closing bracket was expected.
27     tests/files/create-noname.sql:1.13:Error: At least one column definition was expected.
28
29
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
40 ============
41 Dependencies
42 ============
43 - PEAR's `Console_Commandline`__
44 - `udan11's SqlParser`__, which is used by `phpMyAdmin`__
45
46 __ http://pear.php.net/package/Console_CommandLine
47 __ https://github.com/udan11/sql-parser
48 __ https://www.phpmyadmin.net/
49
50
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.
74
75
76 =================
77 About PHP-SQLlint
78 =================
79
80 License
81 =======
82 ``php-sqllint`` is licensed under the `AGPL v3`__ or later.
83
84 __ http://www.gnu.org/licenses/agpl.html
85
86
87 Homepage
88 ========
89 Home page
90    http://cweiske.de/php-sqllint.htm
91 Source code
92    http://git.cweiske.de/php-sqllint.git
93
94    Mirror: https://github.com/cweiske/php-sqllint
95
96
97 Author
98 ======
99 Written by Christian Weiske, cweiske@cweiske.de