Skip to content

Commit 2d9b36d

Browse files
committed
update: rename laravel from 4.2.11 to 4.2.16 and force add vendor in sample app
1 parent 6119055 commit 2d9b36d

File tree

3,359 files changed

+456491
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,359 files changed

+456491
-2
lines changed

cmder/bin/l4installer.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ goto:eof
1818
echo Creating application...
1919

2020
:: Extra files
21-
7za x %WAGON_ROOT%\laravel\4.2.11.zip -o%WAGON_ROOT%\uwamp\www\%PROJECT_NAME% -y > nul
21+
7za x %WAGON_ROOT%\laravel\4.2.16.zip -o%WAGON_ROOT%\uwamp\www\%PROJECT_NAME% -y > nul
2222

2323
:: Change to www folder
2424
cd %WAGON_ROOT%\uwamp\www\%PROJECT_NAME%
File renamed without changes.

uwamp/www/laravel/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/bootstrap/compiled.php
2-
/vendor
32
composer.phar
43
composer.lock
54
.env.*.php

uwamp/www/laravel/vendor/autoload.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
// autoload.php @generated by Composer
4+
5+
require_once __DIR__ . '/composer' . '/autoload_real.php';
6+
7+
return ComposerAutoloaderInitbb53de87abeeaa797594c4719a32bc43::getLoader();

uwamp/www/laravel/vendor/bin/boris

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
/* vim: set shiftwidth=2 expandtab softtabstop=2: */
5+
6+
require_once __DIR__.'/../lib/autoload.php';
7+
8+
$boris = new \Boris\Boris();
9+
10+
$config = new \Boris\Config();
11+
$config->apply($boris);
12+
13+
$options = new \Boris\CLIOptionsHandler();
14+
$options->handle($boris);
15+
16+
$boris->start();
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#! /usr/bin/env php
2+
<?php
3+
4+
if (file_exists($autoloadPath = __DIR__ . '/../../autoload.php')) {
5+
require_once $autoloadPath;
6+
} else {
7+
require_once __DIR__ . '/vendor/autoload.php';
8+
}
9+
$application = new ClassPreloader\Application();
10+
$application->run();
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
composer.lock
2+
vendor
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2013 Michael Dowling <mtdowling@gmail.com> and contributors
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
Class Preloader for PHP
2+
=======================
3+
4+
This tool is used to generate a single PHP script containing all of the classes
5+
required for a specific use case. Using a single compiled PHP script instead of relying on autoloading can help to improve the performance of specific use cases. For example, if your application executes the same bootstrap code on every request, then you could generate a preloader (the compiled output of this tool) to reduce the cost of autoloading the required classes over and over.
6+
7+
What it actually does
8+
---------------------
9+
10+
This tool listens for each file that is autoloaded, creates a list of files, traverses the parsed PHP file using [PHPParser](https://github.com/nikic/PHP-Parser) and any visitors of a Config object, wraps the code of each file in a namespace block if necessary, and writes the contents of every autoloaded file (in order) to a single PHP file.
11+
12+
Notice
13+
------
14+
15+
This tool should only be used for specific use cases. There is a tradeoff between preloading classes and autoloading classes. The point at which it is no longer beneficial to generate a preloader is application specific. You'll need to perform your own benchmarks to determine if this tool will speed up your application.
16+
17+
Installation
18+
------------
19+
20+
Add the ClassPreloader as a dependency to your composer.json file:
21+
22+
```javascript
23+
{
24+
"require": {
25+
"classpreloader/classpreloader": "1.0.*"
26+
},
27+
"config": {
28+
"bin-dir": "bin"
29+
}
30+
}
31+
```
32+
33+
Using the tool
34+
--------------
35+
36+
You use the bin/classpreloader.php compile command with a few command line flags to generate a preloader.
37+
38+
`--config`: A CSV containing a list of files to combine into a classmap, or the full path to a PHP script that returns an array of classes or a `\ClassPreloader\Config` object.
39+
40+
`--output`: The path to the file to store the compiled PHP code. If the directory does not exist, the tool will attempt to create it.
41+
42+
`--fix_dir`: (defaults to 1) Set to 0 to not replace "__DIR__" constants with the actual directory of the original file.
43+
44+
`--fix_file`: (defaults to 1) Set to 0 to not replace "__FILE__" constants with the actual location of the original file.
45+
46+
Writing a config file
47+
---------------------
48+
49+
Creating a PHP based configuration file is fairly simple. Just include the vendor/classpreloader/classpreloader/src/ClassPreloader/ClassLoader.php file and call the `ClassLoader::getIncludes()` method, passing a function as the only argument. This function should accept a `ClassLoader` object and register the passed in object's autoloader using `$loader->register()`. It is important to register the `ClassLoader` autoloader after all other autoloaders are registered.
50+
51+
An array or `\ClassPreloader\Config` must be returned from the config file. You can attach custom node visitors if you need to perform any sort of translation on each matching file before writing it to the output.
52+
53+
```php
54+
<?php
55+
// Here's an example of creating a preloader for using Amazon DynamoDB and the
56+
// AWS SDK for PHP 2.
57+
58+
require __DIR__ . '/src/ClassPreloader/ClassLoader.php';
59+
60+
use ClassPreloader\ClassLoader;
61+
62+
$config = ClassLoader::getIncludes(function(ClassLoader $loader) {
63+
require __DIR__ . '/vendor/autoload.php';
64+
$loader->register();
65+
$aws = Aws\Common\Aws::factory(array(
66+
'key' => '***',
67+
'secret' => '***',
68+
'region' => 'us-east-1'
69+
));
70+
$client = $aws->get('dynamodb');
71+
$client->listTables()->getAll();
72+
});
73+
74+
// Add a regex filter that requires all classes to match the regex
75+
// $config->addInclusiveFilter('/Foo/');
76+
77+
// Add a regex filter that requires that a class does not match the filter
78+
// $config->addExclusiveFilter('/Foo/');
79+
80+
return $config;
81+
```
82+
83+
You would then run the classpreloader.php script and pass in the full path to the above PHP script.
84+
85+
`php bin/classpreloader.php compile --config="/path/to/the_example.php" --output="/tmp/preloader.php"`
86+
87+
The above command will create a file in /tmp/preloader.php that contains every file that was autoloaded while running the snippet of code in the anonymous function. You would generate this file and include it in your production script.
88+
89+
Automating the process with Composer
90+
------------------------------------
91+
92+
You can automate the process of creating preloaders using Composer's script functionality. For example, if you wanted to automatically create a preloader each time the AWS SDK for PHP is installed, you could define a script like the following in your composer.json file:
93+
94+
```javascript
95+
{
96+
"require": {
97+
"classpreloader/classpreloader": "1.0.*"
98+
},
99+
"scripts": {
100+
"post-autoload-dump": "php bin/classpreloader.php compile --config=/path/to/the_example.php --output=/path/to/preload.php"
101+
},
102+
"config": {
103+
"bin-dir": "bin"
104+
}
105+
}
106+
```
107+
108+
Using the above composer.json file, each time the project's autoloader is recreated using the install or update command, the classpreloader.php file will be executed. This script would generate a preload.php containing the classes required to run the previously demonstrated "the_example.php" configuration file.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#! /usr/bin/env php
2+
<?php
3+
4+
if (file_exists($autoloadPath = __DIR__ . '/../../autoload.php')) {
5+
require_once $autoloadPath;
6+
} else {
7+
require_once __DIR__ . '/vendor/autoload.php';
8+
}
9+
$application = new ClassPreloader\Application();
10+
$application->run();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "classpreloader/classpreloader",
3+
"description":"Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific use case",
4+
"keywords":["autoload","class","preload"],
5+
"license":"MIT",
6+
7+
"require":{
8+
"php": ">=5.3.3",
9+
"symfony/console": "~2.1",
10+
"symfony/filesystem": "~2.1",
11+
"symfony/finder": "~2.1",
12+
"nikic/php-parser": "~0.9"
13+
},
14+
15+
"autoload": {
16+
"psr-0": {
17+
"ClassPreloader": "src/"
18+
}
19+
},
20+
21+
"bin": ["classpreloader.php"],
22+
23+
"extra": {
24+
"branch-alias": {
25+
"dev-master": "1.0-dev"
26+
}
27+
}
28+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace ClassPreloader;
4+
5+
use Symfony\Component\Finder\Finder;
6+
use Symfony\Component\Console\Application as BaseApplication;
7+
8+
/**
9+
* ClassPreloader application CLI
10+
*/
11+
class Application extends BaseApplication
12+
{
13+
public function __construct()
14+
{
15+
parent::__construct('ClassPreloader');
16+
17+
// Create a finder to find each non-abstract command in the filesystem
18+
$finder = new Finder();
19+
$finder->files()
20+
->in(__DIR__ . '/Command')
21+
->notName('Abstract*')
22+
->name('*.php');
23+
24+
// Add each command to the CLI
25+
foreach ($finder as $file) {
26+
$filename = str_replace('\\', '/', $file->getRealpath());
27+
$pos = strrpos($filename, '/ClassPreloader/') + strlen('/ClassPreloader/');
28+
$class = __NAMESPACE__ . '\\'
29+
. substr(str_replace('/', '\\', substr($filename, $pos)), 0, -4);
30+
$this->add(new $class());
31+
}
32+
}
33+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
3+
namespace ClassPreloader;
4+
5+
/**
6+
* Maintains a list of classes using a sort of doubly-linked list
7+
*/
8+
class ClassList
9+
{
10+
/**
11+
* @var ClassNode The head node of the list
12+
*/
13+
protected $head;
14+
15+
/**
16+
* @var ClassNode The current node of the list
17+
*/
18+
protected $current;
19+
20+
public function __construct()
21+
{
22+
$this->clear();
23+
}
24+
25+
/**
26+
* Clear the contents of the list and reset the head node and current node
27+
*/
28+
public function clear()
29+
{
30+
$this->head = new ClassNode(null);
31+
$this->current = $this->head;
32+
}
33+
34+
/**
35+
* Traverse to the next node in the list
36+
*/
37+
public function next()
38+
{
39+
if (isset($this->current->next)) {
40+
$this->current = $this->current->next;
41+
} else {
42+
$this->current->next = new ClassNode(null, $this->current);
43+
$this->current = $this->current->next;
44+
}
45+
}
46+
47+
/**
48+
* Insert a value at the current position in the list. Any currently set
49+
* value at this position will be pushed back in the list after the new
50+
* value
51+
*
52+
* @param mixed $value Value to insert
53+
*/
54+
public function push($value)
55+
{
56+
if (!$this->current->value) {
57+
$this->current->value = $value;
58+
} else {
59+
$temp = $this->current;
60+
$this->current = new ClassNode($value, $temp->prev);
61+
$this->current->next = $temp;
62+
$temp->prev = $this->current;
63+
if ($temp === $this->head) {
64+
$this->head = $this->current;
65+
} else {
66+
$this->current->prev->next = $this->current;
67+
}
68+
}
69+
}
70+
71+
/**
72+
* Traverse the ClassList and return a list of classes
73+
*
74+
* @return array
75+
*/
76+
public function getClasses()
77+
{
78+
$classes = array();
79+
$current = $this->head;
80+
while ($current && $current->value) {
81+
$classes[] = $current->value;
82+
$current = $current->next;
83+
}
84+
85+
return array_filter($classes);
86+
}
87+
}

0 commit comments

Comments
 (0)