Selaa lähdekoodia

Finished

master
Pepijn Vdk 2 vuotta sitten
commit
1a4fce8ad9

+ 1
- 0
.gitignore Näytä tiedosto

@@ -0,0 +1 @@
.DS_Store

+ 9
- 0
.htaccess Näytä tiedosto

@@ -0,0 +1,9 @@

# Disable magic quotes by default
# php_value magic_quotes_gpc off

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>

+ 10
- 0
.vscode/settings.json Näytä tiedosto

@@ -0,0 +1,10 @@
{
"workbench.colorCustomizations": {
"editorError.foreground": "#ff000088",
"editorWarning.foreground": "#ffe60033",
"editorInfo.foreground": "#00ff0088",
"activityBar.background": "#411E54",
"titleBar.activeBackground": "#5A2A75",
"titleBar.activeForeground": "#FCF9FD"
}
}

+ 21
- 0
LICENSE Näytä tiedosto

@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2014 Artur Heinze, [http://agentejo.com](http://agentejo.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

+ 275
- 0
README.md Näytä tiedosto

@@ -0,0 +1,275 @@
Lime
====

Lime is a micro web framework for quickly creating web applications in PHP with minimal effort.

```php
$app = new Lime\App();

$app->bind("/", function() {
return "Hello World!";
});

$app->run();
```

Just include one file (~ 35KB) and you're ready to go.


## Routes

In Lime, a route is an HTTP method paired with a URL-matching pattern. Each route is associated with a block:

```php
$app->get("/", function() {
return "This was a GET request...";
});

$app->post("/", function() {
return "This was a POST request...";
});

$app->bind("/", function() {
return "This was a GET or POST request...";
});
```

Routes are matched in the order they are defined. The first route that matches the request is invoked.

Route patterns may include named parameters, accessible via the params hash:

```php
$app->get("/posts/:id/:name", function($params) {
return $params["id"].'-'.$params["name"];
});

$app->post("/misc/*", function($params) {
return $params[":splat"];
});

$app->bind("#/pages/(about|contact)#", function($params) {
return implode("\n", $params[":captures"]);
});
```


## Conditions

Routes may include a variety of matching conditions, such as the user agent:

```php
$app->get("/foo", function() {
// GET request...
}, strpos($_SERVER['HTTP_USER_AGENT'], "Safari")!==false);
```

## Create Urls

```php
$route = $app->routeUrl('/my/route');
$url = $app->baseUrl('/assets/script.js');
```

## Templates

In general you can utilize any template engine you want. Lime provides a simple template engine:

```php
$app->get("/", function() {

$data = array(
"name" => 'Frank',
"title" => 'Template demo'
);

return $this->render("views/view.php with views/layout.php", $data);
});
```

views/view.php:

```php
<p>
Hello <?=$name?>.
</p>
```

views/layout.php:

```php
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title><?=$title?></title>
</head>
<body>
<a href="<?=$this->routeUrl('/')?>">Home</a>
<hr>
<?php echo $content_for_layout;?>
</body>
</html>
```

## You like OO style?

Just bind a class:

```php
class Pages {

protected $app;

public function __construct($app){
$this->app = $app;
}

/*
accessible via
/pages or /pages/index
*/
public function index() {
return $this->app->render("pages/index.php");
}

/*
accessible via
/pages/contact
*/
public function contact() {
return $this->app->render("pages/contact.php");
}

/*
accessible via
/pages/welcome/foo
*/
public function welcome($name) {
return $this->app->render("pages/welcome.php", array("name"=>$name));
}
}

// bind Class to map routes
$app->bindClass("Pages");
```

## Registry

Store any values by setting a key to the $app object.

```php
$app["config.mykey"] = array('test' => 123);
```

Path access helper with <code>/</code>

```php
$value = $app["config.mykey/test"]; // will return 123
```

## Paths

Register paths for quicker access

```php
$app->path('views', __DIR__.'/views');

$view = $app->path('views:detail.php');
$view = $app->render('views:detail.php');
```

Gets url to file

```php
$url = $app->pathToUrl('folder/file.php');
$url = $app->pathToUrl('view:file.php');
```

## Dependency injection

```php
$app->service("db", function(){

// object will be lazy created after accessing $app['db']
$obj = new PDO(...);

return $obj;

});

$app["db"]->query(...);
```

## Events


```php

// register callback
$app->on("customevent", function(){
// code to execute on event
}, $priority = 0);

// trigger custom events
$app->trigger("customevent", $params=array());
```

You can utilize three system events: before, after and shutdown

```php
// render custom error pages

$app->on("after", function() {

switch($this->response->status){
case "404":
$this->response->body = $this->render("views/404.php");
break;
case "500":
$this->response->body = $this->render("views/500.php");
break;
}
});
```




## Helpers

You can extend Lime by using your custom helpers:

```php
class MyHelperClass extends Lime\Helper {

public function test(){
echo "Hello!";
}
}

$app->helpers["myhelper"] = 'MyHelperClass';

$app("myhelper")->test();
```

#### Build in helpers

**Session**

```php
$app("session")->init($sessionname=null);
$app("session")->write($key, $value);
$app("session")->read($key, $default=null);
$app("session")->delete($key);
$app("session")->destroy();
```

**Cache**

```php
$app("cache")->setCachePath($path);
$app("cache")->write($key, $value, $duration = -1);
$app("cache")->read($key, $default=null);
$app("cache")->delete($key);
$app("cache")->clear();
```

+ 25
- 0
composer.json Näytä tiedosto

@@ -0,0 +1,25 @@
{
"name": "aheinze/lime",
"description": "The PHP micro-framework",
"keywords": ["php", "micro-framework", "microframework", "lime"],
"homepage": "https://github.com/aheinze/Lime",
"license": "MIT",
"authors": [
{
"name": "Artur Heinze",
"email": "faulancer@gmail.com",
"homepage": "http://agentejo.com/",
"role": "Developer"
}
],

"require": {
"php": ">=5.6.0"
},

"autoload": {
"psr-4": {
"Lime\\": "src/"
}
}
}

+ 20
- 0
composer.lock Näytä tiedosto

@@ -0,0 +1,20 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "23853615a827859dfd15c68fc7ca4b77",
"packages": [],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=5.6.0"
},
"platform-dev": [],
"plugin-api-version": "2.0.0"
}

+ 40
- 0
index.php Näytä tiedosto

@@ -0,0 +1,40 @@
<?php

use Lime\Controller\BlogController;
use Lime\Controller\UserController;

require_once("src/Lime/App.php");
require __DIR__ . "/vendor/autoload.php";
session_start();

// Aanmaken van global variables
if (!isset($_SESSION['blogs'])) {
$_SESSION['blogs'] = [];
}
if (!isset($_SESSION['users'])) {
$_SESSION['users'] = [
['username' => 'ruben', 'pass' => 'db'],
['username' => 'primi', 'pass' => 'tivo'],
['username' => 'syntra', 'pass' => '123'],
];
}
// $_SESSION = [];
$app = new Lime\App();


$app->bind("/", function () use ($app) {
// variables for template
$data = [
'title' => "Smoelbook",
'blogs' => $_SESSION['blogs'],
'users' => $_SESSION['users'],
];
// Template rendering
return $this->render("pages/blogs.php with pages/layout.php", $data);
});

// Controllers linken aan een route, de functie naam in de controller komt achter de slug die meegegeven wordt => blog/functionName, user/functionName
$app->bindClass(BlogController::class, 'blog');
$app->bindClass(UserController::class, 'user');

$app->run();

+ 58
- 0
pages/blogs.php Näytä tiedosto

@@ -0,0 +1,58 @@
<?php foreach ($blogs as $key => $value) { ?>
<div class="blog">
<div class="blog__title">
Blog #<?= $value['id'] . ' - ' . $value['user'] ?>
<span><?= $value['date'] ?></span>
<div class="blog__title--actions">
<form action="blog/like/<?php echo $key; ?>" method="post">
<input type="submit" name="like" value="Like">
</form>
<form action="blog/delete/<?php echo $key; ?>" method="post">
<input type="submit" value="Delete ">
</form>
</div>
</div>
<div class="blog__body">
<div class="blog__body--message">
<p><?= $value['message'] ?></p>
<span> likes: <?= $value['likes']['count'] ?></span>
</div>

<!-- <a href="#">Attempt to make yourself intresting</a> -->
</div>
</div>
<div class="comment">
<?php if (!empty($value['responses'])) {

echo "<h4 class='comment__title'>Comments:</h4>";

foreach ($value['responses'] as $key2 => $response) { ?>
<div class="blog__reaction">

<div class="blog__reaction--wrapper"><span class="blog__reaction--user"><?= $response['user'] ?>:

</span><?= $response['message'] ?></div>

<div class="blog__reaction--info">

<span class="blog__reaction--date">
<?= $response['date']; ?>
</span>
<form action="blog/likeReaction/<?php echo $key . '-' . $key2; ?>" method="post">
<input type="submit" name="like" value="Like">
</form>
<span> likes: <?= $response['likes']['count'] ?></span>
</div>
</div>
<?php }
} ?>
<div class="comment__action">
<form action="blog/create/<?php echo $key; ?>" method="POST">
<input type="text" name="comment" id="comment">
<input type="submit" value="Comment">
</form>
</div>
</div>
<?php }
// echo '<pre>' . var_export($_SESSION['blogs'], true) . '</pre>';
?>

+ 203
- 0
pages/layout.php Näytä tiedosto

@@ -0,0 +1,203 @@
<?php session_start(); ?>
<!DOCTYPE HTML>
<html lang="en-US">

<head>
<meta charset="UTF-8">
<title><?= $title ?></title>
<style>
* {
box-sizing: border-box;
font-family: helvetica;
}

html,
body {
padding: 0;

margin: 0;
}

nav {
width: 100%;
min-height: 80px;
background-color: goldenrod;
color: white;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;

}

nav h1 {
margin-bottom: 0;
}

main {
max-width: 800px;
padding: 2em;
margin: 0 auto;
}

.users table {
width: 100%;
border: 1px solid black;
border-collapse: collapse;
}

td {
border: 1px solid black;
text-align: center;
}

#createBlog {
display: flex;
flex-direction: column;
}

#createBlog>* {
margin: .2em 0;
padding: 1em;
}

#createBlog>label {
padding: unset;
padding: 1em 0
}

#createBlog>input[type=submit] {
background-color: goldenrod;
border: none;
font-size: 2em;
padding: .2em;
color: white;
cursor: pointer;
}

.blog {
border: 1px solid goldenrod;
margin-top: 1em;
}


.blog__title {
padding: .5em;
background-color: goldenrod;
display: flex;
justify-content: space-between;
}

.blog__title--actions {
display: flex;
align-items: center;
}

.blog__body {
padding: .5em;
width: 100%;
}

.blog__body--message {
display: flex;
align-items: center;
justify-content: space-between;
}

.blog__action {
float: right;
}


.comment {
border: 1px solid goldenrod;
border-top: unset;
padding: 1em;
}

.comment__title {
margin-top: 0;
}

.blog__reaction {
margin-bottom: 1em;
margin-left: 1em;
display: flex;
/* flex-direction: column; */
justify-content: space-between;
}

.blog__reaction--info {
display: flex;
align-items: center;
justify-content: space-around;
}

.blog__reaction--info>* {
margin: 0 .2em;
}

.blog__reaction--user {
font-weight: bold;
color: darkblue;
}
</style>
</head>

<body>
<nav>
<h1><?= $title ?></h1>
<!-- KNOP om uit te loggen indien ingelogd -->
<?php if ($_SESSION['login']['logged_in'] === true) { ?>
<form action="user/logout" method="post">
<input type="submit" value="Log Out">
</form>
<?php } ?>
</nav>
<main>
<!-- Als user ingeligd is, blogs schrijven en content zien -->
<?php if ($_SESSION['login']['logged_in'] === true) { ?>
<form action="blog/create" method='post' id="createBlog">
<label for="blog">Write something...</label>
<textarea name="blog" id="blog" cols="30" rows="5" autofocus required></textarea>
<input type="submit" value="Write blog">
</form>
<?= $content_for_layout; ?>

<?php } else { ?>
<!--
LOGIN (logged_in = false)
-->
<form action="user/login" method='post' id="createBlog">
<label for="username">Username</label>
<input type="text" name="username" id="username" required autofocus>
<label for="pass">Password</label>
<input type="password" name="pass" id="pass" required>
<input type="submit" value="Log in ">
</form>
<?php
// Indien er een fout is bij ingloggen
if (isset($_SESSION['login']['err'])) {
echo $_SESSION['login']['err'];
}

?>
<div class="users">
<table>
<tr>
<th>Usernames</th>
<th>Passwords</th>
</tr>
<?php foreach ($users as $value) { ?>
<tr>
<td><?= $value['username'] ?></td>
<td><?= $value['pass'] ?></td>
</tr>
<?php } ?>
</table>
</div>
<?php } ?>
</main>
</body>

</html>

+ 89
- 0
src/Controller/BlogController.php Näytä tiedosto

@@ -0,0 +1,89 @@
<?php

namespace Lime\Controller;

session_start();
class BlogController
{

protected $app;

public function __construct($app)
{
$this->app = $app;
}
public function create($id = null)
{
date_default_timezone_set("Europe/Brussels");
// Als er een parameter wordt meegegeven
// Dwz dat er een ID is meegegeven voor een reactie toe te voegen
if (isset($id)) {
if (isset($_SESSION['blogs'][$id]['responses'])) {
$respId = count($_SESSION['blogs'][$id]['responses']) + 1;
} else {
$respId = 1;
}
$_SESSION['blogs'][$id]['responses'][] = [
"id" => $respId,
"user" => $_SESSION['login']['user'],
"message" => trim($_POST['comment']),
"parent_id" => $id,
"likes" => ["users" => [], 'count' => 0],
"date" => date("d/m/Y - h:i")
];
if (isset($_SESSION['like'])) {
$_SESSION['blogs'][$id]['likes']++;
}
} else {
// Else -> bij een nieuwe blog
// !empty -> geen lege blogs posten
if (!empty($_POST['blog'])) {
$id = count($_SESSION['blogs']) + 1;

$_SESSION['blogs'][] = [
"id" => $id,
"user" => $_SESSION['login']['user'],
"message" => trim($_POST['blog']),
"likes" => ["users" => [], 'count' => 0],
"date" => date("d/m/Y - h:i")
];
};
}


// Header already sent? -> Je kan geen var_dump of echo doen als je gaat redirecten. Didn't know :)
$this->app->reroute("/");
}
public function delete($params)
{
if (isset($params)) {
unset($_SESSION['blogs'][$params]);
$this->app->reroute("/");
}
}
public function like($params)
{
if (isset($params)) {
// Als de huidige user niet al eens een like gegeven heeft
if (!in_array($_SESSION['login']['user'], $_SESSION['blogs'][$params]['likes']['users'])) {
$_SESSION['blogs'][$params]['likes']['count']++;
// users worden bijgehouden, dan kan er in de toekomst een visuele weergave van wie een like gaf plaatsvinden
$_SESSION['blogs'][$params]['likes']['users'][] = $_SESSION['login']['user'];
}
}
$this->app->reroute("/");
}
public function likeReaction($params)
{
$blogId = explode('-', $params)[0];
$reactionId = explode('-', $params)[1];
if (isset($params)) {
// Als de huidige user niet al eens een like gegeven heeft
if (!in_array($_SESSION['login']['user'], $_SESSION['blogs'][$blogId]['responses'][$reactionId]['likes']['users'])) {
$_SESSION['blogs'][$blogId]['responses'][$reactionId]['likes']['count']++;
$_SESSION['blogs'][$blogId]['responses'][$reactionId]['likes']['users'][] = $_SESSION['login']['user'];
}
}
$this->app->reroute("/");
}
}

+ 41
- 0
src/Controller/UserController.php Näytä tiedosto

@@ -0,0 +1,41 @@
<?php

namespace Lime\Controller;

session_start();
class UserController
{

protected $app;

public function __construct($app)
{
$this->app = $app;
}
public function login()
{
// Cancel
if (!isset($_POST)) return;
$_SESSION['login']['err'] = "";

// Checken of user bestaat
foreach ($_SESSION['users'] as $user) {
if ($user['username'] === trim($_POST['username'])) {
if ($user['pass'] === trim($_POST['pass'])) {
$_SESSION['login']['logged_in'] = true;
$_SESSION['login']['user'] = $_POST['username'];
} else {
$_SESSION['login']['logged_in'] = false;
$_SESSION['login']['err'] = "Login failed";
}
}
}
$this->app->reroute("/");
}
public function logout()
{
if (!isset($_POST)) return;
$_SESSION['login']['logged_in'] = false;
$this->app->reroute("/");
}
}

+ 1749
- 0
src/Lime/App.php
File diff suppressed because it is too large
Näytä tiedosto


+ 7
- 0
vendor/autoload.php Näytä tiedosto

@@ -0,0 +1,7 @@
<?php

// autoload.php @generated by Composer

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit9624755b47867e7382dcc131a8e0dc06::getLoader();

+ 477
- 0
vendor/composer/ClassLoader.php Näytä tiedosto

@@ -0,0 +1,477 @@
<?php

/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Composer\Autoload;

/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see https://www.php-fig.org/psr/psr-0/
* @see https://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
private $vendorDir;

// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();

// PSR-0
private $prefixesPsr0 = array();
private $fallbackDirsPsr0 = array();

private $useIncludePath = false;
private $classMap = array();
private $classMapAuthoritative = false;
private $missingClasses = array();
private $apcuPrefix;

private static $registeredLoaders = array();

public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
}

public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}

return array();
}

public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}

public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}

public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}

public function getClassMap()
{
return $this->classMap;
}

/**
* @param array $classMap Class to filename map
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}

/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}

return;
}

$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;

return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}

/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}

/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}

/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}

/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}

/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}

/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}

/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}

/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}

/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}

/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);

if (null === $this->vendorDir) {
//no-op
} elseif ($prepend) {
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
} else {
unset(self::$registeredLoaders[$this->vendorDir]);
self::$registeredLoaders[$this->vendorDir] = $this;
}
}

/**
* Unregisters this instance as an autoloader.
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));

if (null !== $this->vendorDir) {
unset(self::$registeredLoaders[$this->vendorDir]);
}
}

/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return bool|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);

return true;
}
}

/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}

$file = $this->findFileWithExtension($class, '.php');

// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}

if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}

if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}

return $file;
}

/**
* Returns the currently registered loaders indexed by their corresponding vendor directories.
*
* @return self[]
*/
public static function getRegisteredLoaders()
{
return self::$registeredLoaders;
}

private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;

$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}

// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}

// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}

if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}

// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}

// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}

return false;
}
}

/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}

+ 284
- 0
vendor/composer/InstalledVersions.php Näytä tiedosto

@@ -0,0 +1,284 @@
<?php











namespace Composer;

use Composer\Autoload\ClassLoader;
use Composer\Semver\VersionParser;






class InstalledVersions
{
private static $installed = array (
'root' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
),
'reference' => 'c3ad87a89c2466e0a6e17d8b40f22dc2bc550cd8',
'name' => 'aheinze/lime',
),
'versions' =>
array (
'aheinze/lime' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
),
'reference' => 'c3ad87a89c2466e0a6e17d8b40f22dc2bc550cd8',
),
),
);
private static $canGetVendors;
private static $installedByVendor = array();







public static function getInstalledPackages()
{
$packages = array();
foreach (self::getInstalled() as $installed) {
$packages[] = array_keys($installed['versions']);
}


if (1 === \count($packages)) {
return $packages[0];
}

return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
}









public static function isInstalled($packageName)
{
foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) {
return true;
}
}

return false;
}














public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
$constraint = $parser->parseConstraints($constraint);
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));

return $provided->matches($constraint);
}










public static function getVersionRanges($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}

$ranges = array();
if (isset($installed['versions'][$packageName]['pretty_version'])) {
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
}
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
}
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
}
if (array_key_exists('provided', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
}

return implode(' || ', $ranges);
}

throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}





public static function getVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}

if (!isset($installed['versions'][$packageName]['version'])) {
return null;
}

return $installed['versions'][$packageName]['version'];
}

throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}





public static function getPrettyVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}

if (!isset($installed['versions'][$packageName]['pretty_version'])) {
return null;
}

return $installed['versions'][$packageName]['pretty_version'];
}

throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}





public static function getReference($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}

if (!isset($installed['versions'][$packageName]['reference'])) {
return null;
}

return $installed['versions'][$packageName]['reference'];
}

throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}





public static function getRootPackage()
{
$installed = self::getInstalled();

return $installed[0]['root'];
}







public static function getRawData()
{
return self::$installed;
}



















public static function reload($data)
{
self::$installed = $data;
self::$installedByVendor = array();
}




private static function getInstalled()
{
if (null === self::$canGetVendors) {
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
}

$installed = array();

if (self::$canGetVendors) {

foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
}
}
}

$installed[] = self::$installed;

return $installed;
}
}

+ 21
- 0
vendor/composer/LICENSE Näytä tiedosto

@@ -0,0 +1,21 @@

Copyright (c) Nils Adermann, Jordi Boggiano

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


+ 10
- 0
vendor/composer/autoload_classmap.php Näytä tiedosto

@@ -0,0 +1,10 @@
<?php

// autoload_classmap.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
);

+ 9
- 0
vendor/composer/autoload_namespaces.php Näytä tiedosto

@@ -0,0 +1,9 @@
<?php

// autoload_namespaces.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
);

+ 10
- 0
vendor/composer/autoload_psr4.php Näytä tiedosto

@@ -0,0 +1,10 @@
<?php

// autoload_psr4.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
'Lime\\' => array($baseDir . '/src'),
);

+ 57
- 0
vendor/composer/autoload_real.php Näytä tiedosto

@@ -0,0 +1,57 @@
<?php

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit9624755b47867e7382dcc131a8e0dc06
{
private static $loader;

public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}

/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}

require __DIR__ . '/platform_check.php';

spl_autoload_register(array('ComposerAutoloaderInit9624755b47867e7382dcc131a8e0dc06', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit9624755b47867e7382dcc131a8e0dc06', 'loadClassLoader'));

$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';

call_user_func(\Composer\Autoload\ComposerStaticInit9624755b47867e7382dcc131a8e0dc06::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}

$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}

$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}

$loader->register(true);

return $loader;
}
}

+ 36
- 0
vendor/composer/autoload_static.php Näytä tiedosto

@@ -0,0 +1,36 @@
<?php

// autoload_static.php @generated by Composer

namespace Composer\Autoload;

class ComposerStaticInit9624755b47867e7382dcc131a8e0dc06
{
public static $prefixLengthsPsr4 = array (
'L' =>
array (
'Lime\\' => 5,
),
);

public static $prefixDirsPsr4 = array (
'Lime\\' =>
array (
0 => __DIR__ . '/../..' . '/src',
),
);

public static $classMap = array (
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
);

public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit9624755b47867e7382dcc131a8e0dc06::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit9624755b47867e7382dcc131a8e0dc06::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit9624755b47867e7382dcc131a8e0dc06::$classMap;

}, null, ClassLoader::class);
}
}

+ 5
- 0
vendor/composer/installed.json Näytä tiedosto

@@ -0,0 +1,5 @@
{
"packages": [],
"dev": true,
"dev-package-names": []
}

+ 24
- 0
vendor/composer/installed.php Näytä tiedosto

@@ -0,0 +1,24 @@
<?php return array (
'root' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
),
'reference' => 'c3ad87a89c2466e0a6e17d8b40f22dc2bc550cd8',
'name' => 'aheinze/lime',
),
'versions' =>
array (
'aheinze/lime' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
),
'reference' => 'c3ad87a89c2466e0a6e17d8b40f22dc2bc550cd8',
),
),
);

+ 26
- 0
vendor/composer/platform_check.php Näytä tiedosto

@@ -0,0 +1,26 @@
<?php

// platform_check.php @generated by Composer

$issues = array();

if (!(PHP_VERSION_ID >= 50600)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running ' . PHP_VERSION . '.';
}

if ($issues) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
} elseif (!headers_sent()) {
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
}
}
trigger_error(
'Composer detected issues in your platform: ' . implode(' ', $issues),
E_USER_ERROR
);
}

Loading…
Peruuta
Tallenna