Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
cd044b6f
Commit
cd044b6f
authored
Nov 04, 2013
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed the deprecated Compiler class and the doc on the phar
parent
de674e6d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
307 deletions
+0
-307
bin/compile
bin/compile
+0
-9
doc/index.rst
doc/index.rst
+0
-1
doc/phar.rst
doc/phar.rst
+0
-109
src/Silex/Util/Compiler.php
src/Silex/Util/Compiler.php
+0
-188
No files found.
bin/compile
deleted
100755 → 0
View file @
de674e6d
#!/usr/bin/env php
<?php
require_once
__DIR__
.
'/../vendor/autoload.php'
;
use
Silex\Util\Compiler
;
$compiler
=
new
Compiler
();
$compiler
->
compile
();
doc/index.rst
View file @
cd044b6f
...
@@ -17,4 +17,3 @@ Silex
...
@@ -17,4 +17,3 @@ Silex
providers/index
providers/index
web_servers
web_servers
changelog
changelog
phar
doc/phar.rst
deleted
100644 → 0
View file @
de674e6d
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.
Installing
----------
Installing Silex is as easy as downloading the `phar
<http://silex.sensiolabs.org/get/silex.phar>`_ and storing it somewhere on
the disk. Then, require it in your script::
<?php
require_once __DIR__.'/silex.phar';
$app = new Silex\Application();
$app->get('/hello/{name}', function ($name) use ($app) {
return 'Hello '.$app->escape($name);
});
$app->run();
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
src/Silex/Util/Compiler.php
deleted
100644 → 0
View file @
de674e6d
<?php
/*
* This file is part of the Silex framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Silex\Util
;
use
Symfony\Component\Finder\Finder
;
use
Symfony\Component\Process\Process
;
/**
* The Compiler class compiles the Silex framework.
*
* This is deprecated. Use composer instead.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class
Compiler
{
protected
$version
;
/**
* Compiles the Silex source code into one single Phar file.
*
* @param string $pharFile Name of the output Phar file
*/
public
function
compile
(
$pharFile
=
'silex.phar'
)
{
if
(
file_exists
(
$pharFile
))
{
unlink
(
$pharFile
);
}
$process
=
new
Process
(
'git log --pretty="%h %ci" -n1 HEAD'
);
if
(
$process
->
run
()
>
0
)
{
throw
new
\RuntimeException
(
'The git binary cannot be found.'
);
}
$this
->
version
=
trim
(
$process
->
getOutput
());
$phar
=
new
\Phar
(
$pharFile
,
0
,
'silex.phar'
);
$phar
->
setSignatureAlgorithm
(
\Phar
::
SHA1
);
$phar
->
startBuffering
();
$root
=
__DIR__
.
'/../../..'
;
$finder
=
new
Finder
();
$finder
->
files
()
->
ignoreVCS
(
true
)
->
name
(
'*.php'
)
->
notName
(
'Compiler.php'
)
->
exclude
(
'Tests'
)
->
in
(
$root
.
'/src'
)
->
in
(
$root
.
'/vendor/pimple/pimple/lib'
)
->
in
(
$root
.
'/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher'
)
->
in
(
$root
.
'/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation'
)
->
in
(
$root
.
'/vendor/symfony/http-kernel/Symfony/Component/HttpKernel'
)
->
in
(
$root
.
'/vendor/symfony/routing/Symfony/Component/Routing'
)
->
in
(
$root
.
'/vendor/symfony/browser-kit/Symfony/Component/BrowserKit'
)
->
in
(
$root
.
'/vendor/symfony/css-selector/Symfony/Component/CssSelector'
)
->
in
(
$root
.
'/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler'
)
;
foreach
(
$finder
as
$file
)
{
$this
->
addFile
(
$phar
,
$file
);
}
$this
->
addFile
(
$phar
,
new
\SplFileInfo
(
$root
.
'/LICENSE'
),
false
);
$this
->
addFile
(
$phar
,
new
\SplFileInfo
(
$root
.
'/vendor/autoload.php'
));
$this
->
addFile
(
$phar
,
new
\SplFileInfo
(
$root
.
'/vendor/composer/ClassLoader.php'
));
$this
->
addFile
(
$phar
,
new
\SplFileInfo
(
$root
.
'/vendor/composer/autoload_namespaces.php'
));
$this
->
addFile
(
$phar
,
new
\SplFileInfo
(
$root
.
'/vendor/composer/autoload_classmap.php'
));
// Stubs
$phar
->
setStub
(
$this
->
getStub
());
$phar
->
stopBuffering
();
unset
(
$phar
);
}
protected
function
addFile
(
\Phar
$phar
,
\SplFileInfo
$file
,
$strip
=
true
)
{
$path
=
str_replace
(
dirname
(
dirname
(
dirname
(
__DIR__
)))
.
DIRECTORY_SEPARATOR
,
''
,
$file
->
getRealPath
());
$content
=
file_get_contents
(
$file
);
if
(
$strip
)
{
$content
=
self
::
stripWhitespace
(
$content
);
}
$content
=
preg_replace
(
"/const VERSION = '.*?';/"
,
"const VERSION = '"
.
$this
->
version
.
"';"
,
$content
);
$phar
->
addFromString
(
$path
,
$content
);
}
protected
function
getStub
()
{
return
<<<'EOF'
<?php
/*
* This file is part of the Silex framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
Phar::mapPhar('silex.phar');
require_once 'phar://silex.phar/vendor/autoload.php';
if ('cli' === php_sapi_name() && basename(__FILE__) === basename($_SERVER['argv'][0]) && isset($_SERVER['argv'][1])) {
switch ($_SERVER['argv'][1]) {
case 'update':
$remoteFilename = 'http://silex.sensiolabs.org/get/silex.phar';
$localFilename = __DIR__.'/silex.phar';
file_put_contents($localFilename, file_get_contents($remoteFilename));
break;
case 'check':
$latest = trim(file_get_contents('http://silex.sensiolabs.org/get/version'));
if ($latest != Silex\Application::VERSION) {
printf("A newer Silex version is available (%s).\n", $latest);
} else {
print("You are using the latest Silex version.\n");
}
break;
case 'version':
printf("Silex version %s\n", Silex\Application::VERSION);
break;
default:
printf("Unknown command '%s' (available commands: version, check, and update).\n", $_SERVER['argv'][1]);
}
exit(0);
}
__HALT_COMPILER();
EOF;
}
/**
* Removes whitespace from a PHP source string while preserving line numbers.
*
* Based on Kernel::stripComments(), but keeps line numbers intact.
*
* @param string $source A PHP string
*
* @return string The PHP string with the whitespace removed
*/
public
static
function
stripWhitespace
(
$source
)
{
if
(
!
function_exists
(
'token_get_all'
))
{
return
$source
;
}
$output
=
''
;
foreach
(
token_get_all
(
$source
)
as
$token
)
{
if
(
is_string
(
$token
))
{
$output
.=
$token
;
}
elseif
(
in_array
(
$token
[
0
],
array
(
T_COMMENT
,
T_DOC_COMMENT
)))
{
$output
.=
str_repeat
(
"
\n
"
,
substr_count
(
$token
[
1
],
"
\n
"
));
}
elseif
(
T_WHITESPACE
===
$token
[
0
])
{
// reduce wide spaces
$whitespace
=
preg_replace
(
'{[ \t]+}'
,
' '
,
$token
[
1
]);
// normalize newlines to \n
$whitespace
=
preg_replace
(
'{(?:\r\n|\r|\n)}'
,
"
\n
"
,
$whitespace
);
// trim leading spaces
$whitespace
=
preg_replace
(
'{\n +}'
,
"
\n
"
,
$whitespace
);
$output
.=
$whitespace
;
}
else
{
$output
.=
$token
[
1
];
}
}
return
$output
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment