Skip to content

Instantly share code, notes, and snippets.

@skremiec
Created April 12, 2011 17:42
Show Gist options
  • Save skremiec/916005 to your computer and use it in GitHub Desktop.
Save skremiec/916005 to your computer and use it in GitHub Desktop.
Silex problem
This code works perfectly on two different servers (running PHP 5.3.2 and PHP 5.3.3).
Unfortunately it fails on the third one (PHP 5.3.4).
On very first request, just after downloading silex.phar, it produces:
Fatal error: Class 'Silex\Application' not found in /home/users/abc/public_html/index.php on line 7
And any following request ends with:
Fatal error: Uncaught exception 'PharException' with message '__HALT_COMPILER(); must be declared in a phar' in /home/users/abc/public_html/silex.phar:8
Stack trace:
#0 /home/users/abc/public_html/silex.phar(8): Phar::webPhar(NULL, '_web_stub.php')
#1 /home/users/abc/public_html/index.php(3): require('/home/users/abc...')
#2 {main} thrown in /home/users/abc/public_html/silex.phar on line 8
Any idea what could possibly went wrong?
Full list of failing server's PHP modules, extracted from phpinfo():
- apache2handler
- bcmath
- bz2
- calendar
- Core
- ctype
- curl
- date
- dba
- dio
- dom
- eAccelerator
- ereg
- exif
- fileinfo
- filter
- ftp
- gd
- gettext
- hash
- iconv
- imagick
- imap
- intl
- json
- libxml
- mbstring
- mcrypt
- mhash
- mysql
- mysqli
- mysqlnd
- odbc
- openssl
- pcre
- PDO
- pdo_mysql
- PDO_ODBC
- pdo_pgsql
- pdo_sqlite
- pgsql
- Phar
- posix
- pspell
- Reflection
- session
- shmop
- SimpleXML
- soap
- sockets
- SPL
- SQLite
- sqlite3
- standard
- suhosin
- sysvmsg
- tidy
- tokenizer
- uploadprogress
- wddx
- xml
- xmlreader
- xmlwriter
- xsl
- zip
<?php
require __DIR__.'/silex.phar';
use Silex\Application;
$app = new Application();
$app->match('/', function () {
return 'Works!';
});
$app->run();
@abdev
Copy link

abdev commented Jun 18, 2011

See http://silex-project.org/doc/usage.html#pitfalls
"Phar-Stub bug
Some PHP installations have a bug that throws a PharException when trying to include the Phar. It will also tell you that Silex\Application > could not be found. A workaround is using the following include line:

require_once 'phar://'.__DIR__.'/silex.phar/autoload.php';
The exact cause of this issue could not be determined yet."

@skremiec
Copy link
Author

Thanks for your responses.
After some investigation (and looking into system logs) it turned out that it was caused by the suhosin patch - it was blocking this phar as a potential system security threat.

@estherbrunner
Copy link

The position of the autoload.php in silex.phar seems to have changed. The workaround for the Phar-Stub bug is now:

require_once 'phar://'.__DIR__.'/silex.phar/vendor/.composer/autoload.php';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment