diff --git a/compile b/compile index c6bd713d2..fed4ef7b5 100755 --- a/compile +++ b/compile @@ -3,7 +3,7 @@ require_once __DIR__.'/vendor/autoload.php'; -use Silex\Compiler; +use Silex\Compiler\Util; $compiler = new Compiler(); $compiler->compile(); diff --git a/doc/index.rst b/doc/index.rst index ebc8ddff0..c4af60638 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -13,4 +13,5 @@ Silex internals contributing providers/index - changelog \ No newline at end of file + changelog + phar diff --git a/doc/intro.rst b/doc/intro.rst index e532f4478..aa8132b12 100644 --- a/doc/intro.rst +++ b/doc/intro.rst @@ -22,7 +22,7 @@ step. **Let's go!**:: - require_once __DIR__.'/silex.phar'; + require_once __DIR__.'/vendor/autoload.php'; $app = new Silex\Application(); @@ -32,8 +32,8 @@ step. $app->run(); -All that is needed to get access to the Framework is to include -``silex.phar``. This phar (PHP Archive) file will take care of the rest. +All that is needed to get access to the Framework is to include the +autoloader. Next we define a route to ``/hello/{name}`` that matches for ``GET`` requests. When the route matches, the function is executed and the return @@ -42,7 +42,7 @@ value is sent back to the client. Finally, the app is run. Visit ``/hello/world`` to see the result. It's really that easy! -Installing Silex is as easy as it can get. Download the `silex.phar`_ file -and you're done! +Installing Silex is as easy as it can get. Download the `silex.zip`_ file, +unzip it, and you're done! -.. _silex.phar: http://silex.sensiolabs.org/get/silex.phar +.. _silex.zip: http://silex.sensiolabs.org/get/silex.zip diff --git a/doc/phar.rst b/doc/phar.rst new file mode 100644 index 000000000..58a403d00 --- /dev/null +++ b/doc/phar.rst @@ -0,0 +1,90 @@ +Phar File +--------- + +.. caution:: + + Using the Silex ``phar`` file is deprecated. You should use Composer + instead to install Silex and its dependencies or download one of the + archives. + +Console +~~~~~~~ + +Silex includes a lightweight console for updating to the latest version. + +To find out which version of Silex you are using, invoke ``silex.phar`` on the +command-line with ``version`` as an argument: + +.. code-block:: text + + $ php silex.phar version + Silex version 0a243d3 2011-04-17 14:49:31 +0200 + +To check that your are using the latest version, run the ``check`` command: + +.. code-block:: text + + $ php silex.phar check + +To update ``silex.phar`` to the latest version, invoke the ``update`` +command: + +.. code-block:: text + + $ php silex.phar update + +This will automatically download a new ``silex.phar`` from +``silex.sensiolabs.org`` and replace the existing one. + +Pitfalls +~~~~~~~~ + +There are some things that can go wrong. Here we will try and outline the +most frequent ones. + +PHP configuration +~~~~~~~~~~~~~~~~~ + +Certain PHP distributions have restrictive default Phar settings. Setting +the following may help. + +.. code-block:: ini + + detect_unicode = Off + phar.readonly = Off + phar.require_hash = Off + +If you are on Suhosin you will also have to set this: + +.. code-block:: ini + + suhosin.executor.include.whitelist = phar + +.. note:: + + Ubuntu's PHP ships with Suhosin, so if you are using Ubuntu, you will need + this change. + +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. + +ioncube loader bug +~~~~~~~~~~~~~~~~~~ + +Ioncube loader is an extension that can decode PHP encoded file. +Unfortunately, old versions (prior to version 4.0.9) are not working well +with phar archives. +You must either upgrade Ioncube loader to version 4.0.9 or newer or disable it +by commenting or removing this line in your php.ini file: + +.. code-block:: ini + + zend_extension = /usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so diff --git a/doc/providers/doctrine.rst b/doc/providers/doctrine.rst index 0e3aed157..29dbf357c 100644 --- a/doc/providers/doctrine.rst +++ b/doc/providers/doctrine.rst @@ -60,8 +60,8 @@ Registering .. note:: - Doctrine does not come with the ``silex.zip`, so you need to add Doctrine - DBAL as a dependency to your ``composer.json`` file: + Doctrine does not come with the ``silex`` archives, so you need to add + Doctrine DBAL as a dependency to your ``composer.json`` file: .. code-block:: json diff --git a/doc/providers/monolog.rst b/doc/providers/monolog.rst index a8f374591..b3c3884ca 100644 --- a/doc/providers/monolog.rst +++ b/doc/providers/monolog.rst @@ -48,8 +48,8 @@ Registering .. note:: - Monolog does not come with the ``silex.zip`, so you need to add it as a - dependency to your ``composer.json`` file: + Monolog does not come with the ``silex`` archives, so you need to add it + as a dependency to your ``composer.json`` file: .. code-block:: json diff --git a/doc/providers/swiftmailer.rst b/doc/providers/swiftmailer.rst index 38a086843..8b996d7ee 100644 --- a/doc/providers/swiftmailer.rst +++ b/doc/providers/swiftmailer.rst @@ -23,6 +23,9 @@ Parameters * **encryption**: SMTP encryption, defaults to null. * **auth_mode**: SMTP authentication mode, defaults to null. +* **swiftmailer.class_path** (optional): Path to where the Swift Mailer + library is located. + Services -------- @@ -54,12 +57,14 @@ Registering .. code-block:: php - $app->register(new Silex\Provider\SwiftmailerServiceProvider()); + $app->register(new Silex\Provider\SwiftmailerServiceProvider(), array( + 'swiftmailer.class_path' => __DIR__.'/vendor/swiftmailer/swiftmailer/lib/classes', + )); .. note:: - SwiftMailer does not come with the ``silex.zip`, so you need to add it as - a dependency to your ``composer.json`` file: + SwiftMailer does not come with the ``silex`` archives, so you need to add + it as a dependency to your ``composer.json`` file: .. code-block:: json diff --git a/doc/providers/translation.rst b/doc/providers/translation.rst index 7ec8a5af7..ec2720e89 100644 --- a/doc/providers/translation.rst +++ b/doc/providers/translation.rst @@ -42,8 +42,9 @@ Registering .. note:: - The Symfony Translation component does not come with the ``silex.zip`, so - you need to add it as a dependency to your ``composer.json`` file: + The Symfony Translation component does not come with the ``silex`` + archives, so you need to add it as a dependency to your ``composer.json`` + file: .. code-block:: json diff --git a/doc/providers/twig.rst b/doc/providers/twig.rst index 4e87eb53f..fb59e16d6 100644 --- a/doc/providers/twig.rst +++ b/doc/providers/twig.rst @@ -44,7 +44,7 @@ Registering .. note:: - Twig does not come with the ``silex.zip`, so you need to add it as a + Twig does not come with the ``silex`` archives, so you need to add it as a dependency to your ``composer.json`` file: .. code-block:: json diff --git a/doc/providers/validator.rst b/doc/providers/validator.rst index f3666a62f..6b15f247f 100644 --- a/doc/providers/validator.rst +++ b/doc/providers/validator.rst @@ -37,8 +37,8 @@ Registering .. note:: - The Symfony Validator component does not come with the ``silex.zip`, so - you need to add it as a dependency to your ``composer.json`` file: + The Symfony Validator component does not come with the ``silex`` archives, + so you need to add it as a dependency to your ``composer.json`` file: .. code-block:: json diff --git a/doc/usage.rst b/doc/usage.rst index e1c658c7a..287ef53db 100644 --- a/doc/usage.rst +++ b/doc/usage.rst @@ -6,11 +6,11 @@ This chapter describes how to use Silex. Bootstrap --------- -To include the Silex all you need to do is require the ``silex.phar`` -file and create an instance of ``Silex\Application``. After your -controller definitions, call the ``run`` method on your application:: +To bootstrap Silex, all you need to do is require the ``vendor/autoload.php`` +file and create an instance of ``Silex\Application``. After your controller +definitions, call the ``run`` method on your application:: - require_once __DIR__.'/silex.phar'; + require_once __DIR__.'/vendor/autoload.php'; $app = new Silex\Application(); @@ -718,89 +718,6 @@ correctly, to prevent Cross-Site-Scripting attacks. return $app->json(array('name' => $name)); }); -Console -------- - -Silex includes a lightweight console for updating to the latest -version. - -To find out which version of Silex you are using, invoke ``silex.phar`` on the -command-line with ``version`` as an argument: - -.. code-block:: text - - $ php silex.phar version - Silex version 0a243d3 2011-04-17 14:49:31 +0200 - -To check that your are using the latest version, run the ``check`` command: - -.. code-block:: text - - $ php silex.phar check - -To update ``silex.phar`` to the latest version, invoke the ``update`` -command: - -.. code-block:: text - - $ php silex.phar update - -This will automatically download a new ``silex.phar`` from -``silex.sensiolabs.org`` and replace the existing one. - -Pitfalls --------- - -There are some things that can go wrong. Here we will try and outline the -most frequent ones. - -PHP configuration -~~~~~~~~~~~~~~~~~ - -Certain PHP distributions have restrictive default Phar settings. Setting -the following may help. - -.. code-block:: ini - - detect_unicode = Off - phar.readonly = Off - phar.require_hash = Off - -If you are on Suhosin you will also have to set this: - -.. code-block:: ini - - suhosin.executor.include.whitelist = phar - -.. note:: - - Ubuntu's PHP ships with Suhosin, so if you are using Ubuntu, you will need - this change. - -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. - -ioncube loader bug -~~~~~~~~~~~~~~~~~~ - -Ioncube loader is an extension that can decode PHP encoded file. -Unfortunately, old versions (prior to version 4.0.9) are not working well -with phar archives. -You must either upgrade Ioncube loader to version 4.0.9 or newer or disable it -by commenting or removing this line in your php.ini file: - -.. code-block:: ini - - zend_extension = /usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so - Apache configuration -------------------- diff --git a/example.htaccess b/example.htaccess deleted file mode 100644 index b53633d46..000000000 --- a/example.htaccess +++ /dev/null @@ -1,8 +0,0 @@ - - Options -MultiViews - - RewriteEngine On - #RewriteBase /path/to/app - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^ index.php [L] - diff --git a/src/Silex/Compiler.php b/src/Silex/Util/Compiler.php similarity index 98% rename from src/Silex/Compiler.php rename to src/Silex/Util/Compiler.php index f964a77ef..e8d81d18a 100644 --- a/src/Silex/Compiler.php +++ b/src/Silex/Util/Compiler.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Silex; +namespace Silex\Util; use Symfony\Component\Finder\Finder; use Symfony\Component\HttpKernel\Kernel; @@ -18,6 +18,8 @@ /** * The Compiler class compiles the Silex framework. * + * This is deprecated. Use composer instead. + * * @author Fabien Potencier */ class Compiler