🏆 Learn You PHP! - An introduction to PHP's core features: i/o, http, arrays, exceptions and so on.

Overview

Learn You PHP!

The very first PHP School workshop. A revolutionary new way to learn PHP
Bring your imagination to life in an open learning eco-system


Learn You PHP Workshop

Installation

  1. Install PHP
  2. Install workshop-manager
  3. Run workshop-manager install learnyouphp
  4. Run learnyouphp

learnyouphp will run through a series of PHP workshops. Starting at a basic "Hello World" and moving on to more advanced exercises about dealing with filesystems, objects, exceptions and streams.

Comments
  • Cannot install via composer because of minimum stability

    Cannot install via composer because of minimum stability

    Hello,

    tried installing the package as per instructions, this could not be done because of warning about minimum required stability of packages via composer.

    Ran self-update before trying to install, standard composer install to the best of my knowledge (so no change of minimum stability by me)

    Pic :

    selection_999 298

    invalid 
    opened by Alienpruts 27
  • Question on Ex10

    Question on Ex10

    Is it supposed to be looking at www.time.com, rather than running a web server request on the exercise file? I've glanced through the code, as well as poured over the instructions for the exercise and I'm not seeing where you're supposed to configure anything for the HTTP server that we're implementing.

    Not clear if we're supposed to supply a domain to the script, or if that's supposed to be part of the run/verify scripts.

    opened by devnuhl 18
  • Add first Composer exercise: Dependency Heaven

    Add first Composer exercise: Dependency Heaven

    @AydinHassan Let me know what you think dude.

    Only things I'm questioning atm are

    • Composer is @dev but looks like that's unavoidable at the moment
    • Using POST, did it as an experiment at first but thinking about it in a real world usage these would all be GET requests. What do you think?
    • Composer locker is a bit of a dependency magnet, think I might wrap this in a class in the Workshop instead.
    opened by mikeymike 11
  • Cannot install via composer because need to remove symfony/process

    Cannot install via composer because need to remove symfony/process

    Hi, I'm trying to install via composer. But it always failed even if I'm cleared composer cache. Here is the error message

    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - Conclusion: remove symfony/process v2.6.5
        - Installation request for php-school/learn-you-php ^0.2.10 -> satisfiable by php-school/learn-you-php[0.2.10].
        - Conclusion: don't install symfony/process v3.0.2
        - Conclusion: don't install symfony/process v2.6.5|install symfony/process v3.0.2
        - php-school/learn-you-php 0.2.10 requires php-school/php-workshop ^0.3@dev -> satisfiable by php-school/php-workshop[0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5].
        - php-school/php-workshop 0.3.0 requires symfony/process ^2.7 -> satisfiable by symfony/process[v2.7.0, v2.7.1, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.2].
        - php-school/php-workshop 0.3.1 requires symfony/process ^2.7 -> satisfiable by symfony/process[v2.7.0, v2.7.1, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.2].
        - php-school/php-workshop 0.3.2 requires symfony/process ^2.7 -> satisfiable by symfony/process[v2.7.0, v2.7.1, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.2].
        - php-school/php-workshop 0.3.3 requires symfony/process ^2.7 -> satisfiable by symfony/process[v2.7.0, v2.7.1, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.2].
        - php-school/php-workshop 0.3.4 requires symfony/process ^2.7 -> satisfiable by symfony/process[v2.7.0, v2.7.1, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.2].
        - php-school/php-workshop 0.3.5 requires symfony/process ^2.7|^3.0 -> satisfiable by symfony/process[v2.7.0, v2.7.1, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.2, v3.0.0, v3.0.1, v3.0.2].
        - Can only install one of: symfony/process[v2.7.0, v2.6.5].
        - Can only install one of: symfony/process[v2.7.1, v2.6.5].
        - Can only install one of: symfony/process[v2.7.2, v2.6.5].
        - Can only install one of: symfony/process[v2.7.3, v2.6.5].
        - Can only install one of: symfony/process[v2.7.4, v2.6.5].
        - Can only install one of: symfony/process[v2.7.5, v2.6.5].
        - Can only install one of: symfony/process[v2.7.6, v2.6.5].
        - Can only install one of: symfony/process[v2.7.7, v2.6.5].
        - Can only install one of: symfony/process[v2.7.8, v2.6.5].
        - Can only install one of: symfony/process[v2.7.9, v2.6.5].
        - Can only install one of: symfony/process[v2.8.0, v2.6.5].
        - Can only install one of: symfony/process[v2.8.1, v2.6.5].
        - Can only install one of: symfony/process[v2.8.2, v2.6.5].
        - Can only install one of: symfony/process[v3.0.0, v2.6.5].
        - Can only install one of: symfony/process[v3.0.1, v2.6.5].
        - Installation request for symfony/process == 2.6.5.0 -> satisfiable by symfony/process[v2.6.5].
    
    
    Installation failed, reverting ./composer.json to its original content.
    

    I'm using php 5.6.16

    > php -v
    PHP 5.6.16 (cli) (built: Dec 13 2015 15:06:28) 
    Copyright (c) 1997-2015 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
        with Xdebug v2.3.3, Copyright (c) 2002-2015, by Derick Rethans
    
    opened by reyhansofian 9
  • Class 'ZipArchive' not found when try to install learnyouphp

    Class 'ZipArchive' not found when try to install learnyouphp

    Hi,

    I have installed and I verify that everything is ok with workshop-manager in my machine with ubuntu and php 7.0.12 but when I tried to install learnyouphp I got this error:

    PHP Fatal error: Uncaught Error: Class 'ZipArchive' not found in phar:///usr/local/bin/workshop-manager/src/Installer/Installer.php:136

    opened by silviuvoicu 8
  • Persist user state in Docker environment

    Persist user state in Docker environment

    Added a docker volume to persist the user's home directory inside the container. I've had to do the whole home dir because compose cannot volume single files, at least not cross platform iirc.

    However there shouldn't be any issues with this because we mount solutions etc into /phpschool which is outside of the home dir so wouldn't cause any conflicts 👍

    opened by mikeymike 6
  • Exercise 3 is ambiguous

    Exercise 3 is ambiguous

    the exercise ask for the number of newlines, but what is the correct answer for strings that without a newline at end? for example, "line1\nline2" should be count as 2 lines, but it actually has only 1 newline char. and the funny part is "wc -l" also show "1" for this case.

    opened by weichenlin 6
  • PHP 8 compatibility issues when installing learnyouphp workshop

    PHP 8 compatibility issues when installing learnyouphp workshop

    I just installed the workshop manager on my machine and verified, this was the return

    ➜  ~ workshop-manager verify
    
    Verifying your installation
    ===========================
    
    
     [OK] Your $PATH environment variable is configured correctly.
    
    
    
     [OK] Your PHP version is 8.0.0, PHP 7.2 is the minimum supported version for this tool. Please note that some workshops
          may require a higher version of PHP, so you may not be able to install them without upgrading PHP.
    
    
    
     [OK] All required PHP extensions are installed. Please note that some workshops may require additional PHP extensions.
    
    

    But when I tried to install the learnyouphp workshop that's what I get:

    ➜  ~ workshop-manager install -vvv learnyouphp
    
    Installing dependencies from lock file
    Verifying lock file contents can be installed on current platform.
    Dependency resolution completed in 0.000 seconds
    Your lock file does not contain a compatible set of packages. Please run composer update.
    
      Problem 1
        - beberlei/assert is locked to version v3.2.7 and an update of this package was not requested.
        - beberlei/assert v3.2.7 requires php ^7 -> your php version (8.0.0) does not satisfy that requirement.
      Problem 2
        - beberlei/assert v3.2.7 requires php ^7 -> your php version (8.0.0) does not satisfy that requirement.
        - php-school/cli-menu 4.1.0 requires beberlei/assert ^2.4 | ^3 -> satisfiable by beberlei/assert[v3.2.7].
        - php-school/cli-menu is locked to version 4.1.0 and an update of this package was not requested.
    
      There was a problem installing dependencies for "learnyouphp". Try running in verbose mode to see more details: /usr/local/bin/workshop-manager install -v
    
    
    In Installer.php line 153:
    
      [PhpSchool\WorkshopManager\Exception\ComposerFailureException]
    
    
    Exception trace:
      at phar:///usr/local/bin/workshop-manager/src/Installer/Installer.php:153
     PhpSchool\WorkshopManager\Installer\Installer->PhpSchool\WorkshopManager\Installer\{closure}() at phar:///usr/local/bin/workshop-manager/src/Filesystem.php:23
     PhpSchool\WorkshopManager\Filesystem->executeInPath() at phar:///usr/local/bin/workshop-manager/src/Installer/Installer.php:155
     PhpSchool\WorkshopManager\Installer\Installer->installWorkshop() at phar:///usr/local/bin/workshop-manager/src/Command/InstallWorkshop.php:33
     PhpSchool\WorkshopManager\Command\InstallWorkshop->__invoke() at n/a:n/a
     call_user_func_array() at phar:///usr/local/bin/workshop-manager/vendor/php-di/invoker/src/Invoker.php:82
     Invoker\Invoker->call() at phar:///usr/local/bin/workshop-manager/vendor/mnapoli/silly/src/Application.php:95
     Silly\Application->Silly\{closure}() at phar:///usr/local/bin/workshop-manager/vendor/symfony/console/Command/Command.php:253
     Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/workshop-manager/vendor/symfony/console/Application.php:971
     Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/workshop-manager/vendor/symfony/console/Application.php:290
     Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/workshop-manager/vendor/symfony/console/Application.php:166
     Symfony\Component\Console\Application->run() at phar:///usr/local/bin/workshop-manager/app/bootstrap.php:49
     require() at phar:///usr/local/bin/workshop-manager/bin/workshop-manager:3
     require() at /usr/local/bin/workshop-manager:11
    
    install <workshopName>
    

    Is there a way to update the dependencies so that it will be possible to run the workshop on php 8 environments?

    opened by stsmuniz 5
  • [DomainException] windows is not supported

    [DomainException] windows is not supported

    I followede all the instructions here : https://www.phpschool.io/install#windows, but still i got [DomainException] windows is not supported error. any suggestion?

    opened by jnasoy 5
  • Exercise 9 instructions incorrect

    Exercise 9 instructions incorrect

    The instructions say that the port will be the first argument to the program, however when verifying, the output errors make it seem like it is sending the port as a second parameter with the localhost ipv4 address as the first argument.

    Upon making adjustments to test this, the program started working, but I have been unable to determine why it is expecting times 12 hours into the future. I could have understood if it was basing on GMT/UTC, but there is no mention of timezone we should be formatting for in the instructions.

    opened by devnuhl 5
  • Translating to Brasilian Portuguese

    Translating to Brasilian Portuguese

    I'd like to translate it to Brasilian Portuguese. what do you think , if we change a bit this folder structure ?

    • /
      • src /
        • en/
        • exercices /
        • pt-br/
          • exercícios /

    it will be more easy to contribute with another languages

    opened by osvaldoabel 5
  • Rewrite exercise to use league/route and symfony/string

    Rewrite exercise to use league/route and symfony/string

    Hey @mikeymike would appreciate a review here.

    Basically all the deps we used in this exercise are not updated and do not work with PHP 8.1. So I had to search for a new routing library library. They are all not very simple, with league/route being the best one I could find. It is still more complicated, requiring you to marshal the request objects and output the responses, so you need to learn about PSR7 as well now and pull in an additional 2 libraries.

    symfony/string seemed like a good alternative for stringy but it doesn't support swapping case so I changed that to snake case.

    Is the problem file understandable or too complicated?

    opened by AydinHassan 0
  • Uncaught Hoa\Socket\Client::_open(): (1) Client returns an error (number 111)

    Uncaught Hoa\Socket\Client::_open(): (1) Client returns an error (number 111)

    On the time-server exercise, I get the following error when running:

    $ learnyouphp verify time.php
    

    time.php is the solution code from here: https://raw.githubusercontent.com/php-school/learn-you-php/master/exercises/time-server/solution/solution.php

    PHP Fatal error:  Uncaught Hoa\Socket\Client::_open(): (1) Client returns an error (number 111): Connection refused while trying to join tcp://127.0.0.1:55019.
    in /home/michael/.php-school/workshops/learnyouphp/vendor/hoa/socket/Client.php at line 191.
      thrown in /home/michael/.php-school/workshops/learnyouphp/vendor/hoa/socket/Client.php on line 191
    
    Fatal error: Uncaught Hoa\Socket\Client::_open(): (1) Client returns an error (number 111): Connection refused while trying to join tcp://127.0.0.1:55019.
    in /home/michael/.php-school/workshops/learnyouphp/vendor/hoa/socket/Client.php at line 191.
      thrown in /home/michael/.php-school/workshops/learnyouphp/vendor/hoa/socket/Client.php on line 191
    
    Hoa\Socket\Exception\Exception: Client returns an error (number 111): Connection refused while trying to join tcp://127.0.0.1:55019. in /home/michael/.php-school/workshops/learnyouphp/vendor/hoa/socket/Client.php on line 191
    
    Call Stack:
        0.0002     360312   1. {main}() /home/michael/.php-school/workshops/learnyouphp/bin/learnyouphp:0
        0.0042     910536   2. PhpSchool\PhpWorkshop\Application->run() /home/michael/.php-school/workshops/learnyouphp/bin/learnyouphp:5
        0.0291    3934080   3. PhpSchool\PhpWorkshop\CommandRouter->route() /home/michael/.php-school/workshops/learnyouphp/vendor/php-school/php-workshop/src/Application.php:194
        0.0529    6942160   4. PhpSchool\PhpWorkshop\CommandRouter->resolveCallable() /home/michael/.php-school/workshops/learnyouphp/vendor/php-school/php-workshop/src/CommandRouter.php:131
        0.0668    7771184   5. PhpSchool\PhpWorkshop\CommandRouter->callCommand() /home/michael/.php-school/workshops/learnyouphp/vendor/php-school/php-workshop/src/CommandRouter.php:213
        0.0668    7771184   6. PhpSchool\PhpWorkshop\Command\VerifyCommand->__invoke() /home/michael/.php-school/workshops/learnyouphp/vendor/php-school/php-workshop/src/CommandRouter.php:233
        0.0668    7771184   7. PhpSchool\PhpWorkshop\ExerciseDispatcher->verify() /home/michael/.php-school/workshops/learnyouphp/vendor/php-school/php-workshop/src/Command/VerifyCommand.php:83
        0.1019    8329080   8. PhpSchool\PhpWorkshop\ExerciseRunner\CliRunner->verify() /home/michael/.php-school/workshops/learnyouphp/vendor/php-school/php-workshop/src/ExerciseDispatcher.php:156
        0.1095    8369832   9. array_map() /home/michael/.php-school/workshops/learnyouphp/vendor/php-school/php-workshop/src/ExerciseRunner/CliRunner.php:143
        0.1095    8369888  10. PhpSchool\PhpWorkshop\ExerciseRunner\CliRunner->PhpSchool\PhpWorkshop\ExerciseRunner\{closure}() /home/michael/.php-school/workshops/learnyouphp/vendor/php-school/php-workshop/src/ExerciseRunner/CliRunner.php:143
        0.1095    8369888  11. PhpSchool\PhpWorkshop\ExerciseRunner\CliRunner->doVerify() /home/michael/.php-school/workshops/learnyouphp/vendor/php-school/php-workshop/src/ExerciseRunner/CliRunner.php:141
        0.1097    8376584  12. PhpSchool\PhpWorkshop\ExerciseRunner\CliRunner->executePhpFile() /home/michael/.php-school/workshops/learnyouphp/vendor/php-school/php-workshop/src/ExerciseRunner/CliRunner.php:182
        0.1107    8383304  13. PhpSchool\PhpWorkshop\Event\EventDispatcher->dispatch() /home/michael/.php-school/workshops/learnyouphp/vendor/php-school/php-workshop/src/ExerciseRunner/CliRunner.php:97
        0.1107    8383304  14. PhpSchool\LearnYouPhp\Exercise\TimeServer->PhpSchool\LearnYouPhp\Exercise\{closure}() /home/michael/.php-school/workshops/learnyouphp/vendor/php-school/php-workshop/src/Event/EventDispatcher.php:44
        0.2144    8735696  15. Hoa\Socket\Client->connect() /home/michael/.php-school/workshops/learnyouphp/src/Exercise/TimeServer.php:80
        0.2145    8735744  16. Hoa\Socket\Client->__construct() /home/michael/.php-school/workshops/learnyouphp/vendor/hoa/socket/Connection/Connection.php:197
        0.2150    8748304  17. Hoa\Socket\Client->open() /home/michael/.php-school/workshops/learnyouphp/vendor/hoa/stream/Stream.php:172
        0.2150    8748304  18. Hoa\Stream\Stream::_getStream() /home/michael/.php-school/workshops/learnyouphp/vendor/hoa/stream/Stream.php:290
        0.2151    8748744  19. Hoa\Socket\Client->_open() /home/michael/.php-school/workshops/learnyouphp/vendor/hoa/stream/Stream.php:213
    
    
    opened by michaellenahan 3
  • Filtered ls cares about order

    Filtered ls cares about order

    If you output the correct results but in a different order to our solution then it will fail. I'm not sure how we would fix this but it's worth a look. Or maybe the best way is to say to do it in a particular order in the exercise task.

    opened by AydinHassan 0
Releases(0.6.1)
A simple, standalone, modern PHP class inspector and mapper library, wrapping PHPs native reflection in a fluent interface

A simple, standalone, modern PHP class inspector and mapper library, wrapping PHPs native reflection in a fluent interface.

smpl 9 Sep 1, 2022
PHP functions that help you validate structure of complex nested PHP arrays.

PHP functions that help you validate structure of complex nested PHP arrays.

cd rubin 7 May 22, 2022
YesilCMS is based on BlizzCMS and specifically adapted for VMaNGOS Core and includes new features and many bug fixes.

YesilCMS · YesilCMS is based on BlizzCMS and specifically adapted for VMaNGOS Core and includes new features and many bug fixes. Features In addition

yesilmen 12 Jan 4, 2023
All PHP functions, rewritten to throw exceptions instead of returning false

Safe PHP This project is deprecated Because of how this project needs to be in sync with the official PHP documentation, maintaining a set of function

TheCodingMachine 2.1k Dec 28, 2022
All PHP functions, rewritten to throw exceptions instead of returning false, now for php8

A set of core PHP functions rewritten to throw exceptions instead of returning false when an error is encountered.

TheCodingMachine 106 Nov 21, 2022
A PocketMine-MP plugin for logging Exceptions to a Sentry server

Sentry A PocketMine-MP plugin for logging Exceptions to a Sentry server. Asynchronous logging If you want to log exceptions in a thread-safe way, you

null 4 Apr 9, 2022
Dobren Dragojević 6 Jun 11, 2023
Type and shape system for arrays. Help write clearer code when implementing configs for your PocketMine-MP plugin or composer project.

ConfigStruct Type and shape system for arrays. Help write clearer code when implementing configs for your PocketMine-MP plugin or composer project. It

EndermanbugZJFC 9 Aug 22, 2022
Safely break down arrays or objects, and put them back together in new shapes.

traverse/reshape traverse() and reshape() are companion functions that safely break down arrays or objects and put them back together in new shapes. t

Alley Interactive 2 Aug 4, 2022
This package was created to provide simple way to manipulate arrays in PHP

PHP Collections This package was created to provide simple way to manipulate arrays in PHP. The package was inspired by the Laravel Collections.

Wojciech Mleczek 13 Jul 26, 2021
Make your PHP arrays sweet'n'safe

Mess We face a few problems in our PHP projects Illogical type casting (PHP's native implementation is way too "smart") Pointless casts like array =>

Artem Zakirullin 192 Nov 28, 2022
Laravel Plans is a package for SaaS apps that need management over plans, features, subscriptions, events for plans or limited, countable features.

Laravel Plans Laravel Plans is a package for SaaS apps that need management over plans, features, subscriptions, events for plans or limited, countabl

ángel 2 Oct 2, 2022
Simple libary for functional programing paradigm with arrays.

rodrigodornelles/php-array-lib simple libary for functional programing paradigm with arrays Features Test driven development style (TDD) PHP version c

null 10 Nov 28, 2022
Michael Pratt 307 Dec 23, 2022
Minimalist PHP frame for Core-Library, for Developing PHP application that gives you the full control of your application.

LazyPHP lightweight Pre-Made Frame for Core-library Install Run the below command in your terminal $ composer create-project ryzen/lazyphp my-first-pr

Ry-Zen 7 Aug 21, 2022
A repository for showcasing my knowledge of the PHP programming language, and continuing to learn the language.

Learning PHP (programming language) I know very little about PHP. This document will list all my knowledge of the PHP programming language. Basic synt

Sean P. Myrick V19.1.7.2 2 Oct 29, 2022
Core - ownCloud gives you freedom and control over your own data.

ownCloud Core ownCloud gives you freedom and control over your own data. A personal cloud which runs on your own server. Why is this so awesome? ?? Ac

ownCloud 7.9k Jan 4, 2023
Learn how to run WordPress with Docker. Read about our experiences and start off with an easy boilerplate.

Hi! We're Dan and Jay. We're a two person team with a passion for open source products. We created Server Side Up to help share what we learn. Find us

Server Side Up 7 Sep 17, 2022
Learn to apply best practices as a PHP backend developer

PHP eCommerce Project Here are the things that this repo will cover: Object oriented programming principles and best practices Object oriented session

Muhammad Salah 0 Aug 2, 2022