Skip to content

Commit

Permalink
First workshop
Browse files Browse the repository at this point in the history
  • Loading branch information
AydinHassan committed Oct 20, 2015
0 parents commit 5f1533e
Show file tree
Hide file tree
Showing 30 changed files with 2,711 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
/vendor
/.idea
program.php
12 changes: 12 additions & 0 deletions .phpstorm.meta.php
@@ -0,0 +1,12 @@
<?php
namespace PHPSTORM_META
{
$STATIC_METHOD_TYPES = [
\DI\Container::get('') => [
"" == "@",
],
\Interop\Container\ContainerInterface::get('') => [
"" == "@",
],
];
}
5 changes: 5 additions & 0 deletions .scrutinizer.yml
@@ -0,0 +1,5 @@
before_commands:
- "composer install --prefer-source"

checks:
php: true
26 changes: 26 additions & 0 deletions .travis.yml
@@ -0,0 +1,26 @@
language: php

php:
- 5.6
- hhvm

install:
- composer self-update
- composer install --dev --prefer-source

before_script:
- mkdir -p build/logs

script:
- ./vendor/bin/phpunit --coverage-clover ./build/logs/clover.xml
- ./vendor/bin/phpcs --standard=PSR2 ./src/
- ./vendor/bin/phpcs --standard=PSR2 ./test/

after_script:
- bash <(curl -s https://codecov.io/bash)
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover ./build/logs/clover.xml

matrix:
allow_failures:
- php: hhvm
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Aydin Hassan

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.
Empty file added README.md
Empty file.
49 changes: 49 additions & 0 deletions app/bootstrap.php
@@ -0,0 +1,49 @@
<?php

ini_set('display_errors', 1);
date_default_timezone_set('Europe/London');
switch (true) {
case (file_exists(__DIR__ . '/../vendor/autoload.php')):
// Installed standalone
require __DIR__ . '/../vendor/autoload.php';
break;
case (file_exists(__DIR__ . '/../../../autoload.php')):
// Installed as a Composer dependency
require __DIR__ . '/../../../autoload.php';
break;
case (file_exists('vendor/autoload.php')):
// As a Composer dependency, relative to CWD
require 'vendor/autoload.php';
break;
default:
throw new RuntimeException('Unable to locate Composer autoloader; please run "composer install".');
}

use PhpSchool\PhpWorkshop\Application;
use PhpSchool\LearnYouPhp\Exercise\BabySteps;
use PhpSchool\LearnYouPhp\Exercise\FilteredLs;
use PhpSchool\LearnYouPhp\Exercise\HelloWorld;
use PhpSchool\LearnYouPhp\Exercise\MyFirstIo;

$app = new Application(null, __DIR__ . '/config.php');

$app->addExercise(HelloWorld::class);
$app->addExercise(BabySteps::class);
$app->addExercise(MyFirstIo::class);
$app->addExercise(FilteredLs::class);

$art = <<<ART
_ __ _
/ |..| \
\/ || \/
|_''_|
PHP SCHOOL
LEARNING FOR ELEPHPANTS
ART;

$app->setLogo($art);
$app->setFgColour('green');
$app->setBgColour('black');

return $app;
23 changes: 23 additions & 0 deletions app/config.php
@@ -0,0 +1,23 @@
<?php

use function DI\factory;
use function DI\object;
use Interop\Container\ContainerInterface;
use PhpSchool\LearnYouPhp\Exercise\BabySteps;
use PhpSchool\LearnYouPhp\Exercise\FilteredLs;
use PhpSchool\LearnYouPhp\Exercise\HelloWorld;
use PhpSchool\LearnYouPhp\Exercise\MyFirstIo;
use Symfony\Component\Filesystem\Filesystem;
use Faker\Factory as FakerFactory;

return [
//Exercises
BabySteps::class => object(BabySteps::class),
HelloWorld::class => object(HelloWorld::class),
MyFirstIo::class => factory(function (ContainerInterface $c) {
return new MyFirstIo($c->get(Filesystem::class), FakerFactory::create());
}),
FilteredLs::class => factory(function (ContainerInterface $c) {
return new FilteredLs($c->get(Filesystem::class));
}),
];
28 changes: 28 additions & 0 deletions appveyor.yml
@@ -0,0 +1,28 @@
build: false
platform: 'x86'
clone_folder: C:\projects\my-php-workshop
branches:
except:
- gh-pages

init:
- SET COMPOSER_NO_INTERACTION=1

install:
- SET PATH=C:\Program Files\OpenSSL;%PATH%
- cinst php
- cd c:\tools\php
- copy php.ini-production php.ini
- echo date.timezone="UTC" >> php.ini
- echo extension_dir=ext >> php.ini
- echo extension=php_openssl.dll >> php.ini
- echo extension=php_mbstring.dll >> php.ini
- SET PATH=C:\tools\php;%PATH%
- cd C:\projects\my-php-workshop
- php -r "readfile('http://getcomposer.org/installer');" | php
- php composer.phar install --prefer-source --no-progress

test_script:
- ps: cd C:\projects\my-php-workshop
- ps: gl
- vendor\bin\phpunit.bat
4 changes: 4 additions & 0 deletions bin/learnyouphp
@@ -0,0 +1,4 @@
<?php

$app = require_once __DIR__ . '/../app/bootstrap.php';
exit($app->run());
29 changes: 29 additions & 0 deletions composer.json
@@ -0,0 +1,29 @@
{
"name": "php-school/learn-you-php",
"description": "Learn You PHP",
"license": "MIT",
"authors": [
{
"name": "Aydin Hassan",
"email": "aydin@hotmail.co.uk"
}
],
"require" : {
"php" : ">=5.6",
"php-school/php-workshop": "~1.0",
"nikic/php-parser": "dev-master#98d28d7aa04e2d92fea2b375373878d0b1fce992"
},
"require-dev": {
"phpunit/phpunit": "~4.1",
"squizlabs/php_codesniffer": "~2.0"
},
"autoload" : {
"psr-4" : {
"PhpSchool\\LearnYouPhp\\": "src"
}
},
"autoload-dev": {
"psr-4": { "PhpSchool\\LearnYouPhpTest\\": "test/" }
},
"bin": ["bin/learnyouphp"]
}

0 comments on commit 5f1533e

Please sign in to comment.