Skip to content

Commit 3deabd9

Browse files
authored
Merge pull request #70 from php-school/clarify-hello-world-instructions
Clarify hello world instructions
2 parents 8800750 + 9839805 commit 3deabd9

File tree

4 files changed

+88
-53
lines changed

4 files changed

+88
-53
lines changed

app/config.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use PhpSchool\LearnYouPhp\Exercise\TimeServer;
1717
use PhpSchool\LearnYouPhp\Exercise\DependencyHeaven;
1818
use PhpSchool\LearnYouPhp\TcpSocketFactory;
19+
use PhpSchool\PhpWorkshop\Event\Event;
1920
use Symfony\Component\Filesystem\Filesystem;
2021
use Faker\Factory as FakerFactory;
2122

@@ -51,5 +52,15 @@
5152
}),
5253
DependencyHeaven::class => factory(function (ContainerInterface $c) {
5354
return new DependencyHeaven(FakerFactory::create('fr_FR'));
54-
})
55+
}),
56+
57+
'eventListeners' => [
58+
'exercise.selected.hello-world' => [
59+
function () {
60+
if (!file_exists('hello-world.php')) {
61+
touch('hello-world.php');
62+
}
63+
}
64+
]
65+
]
5566
];

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"require" : {
1515
"php" : ">=5.6",
1616
"ext-pdo_sqlite": "*",
17-
"php-school/php-workshop": "^0.5",
17+
"php-school/php-workshop": "^1.2",
1818
"hoa/socket": "^1.0",
1919
"php-school/workshop-installer": "^0.1"
2020
},

composer.lock

Lines changed: 53 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exercises/hello-world/problem/problem.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,34 @@ To make a PHP program, create a new file with a `.php` extension and start writi
1010
$ php program.php
1111
```
1212

13-
You can write to the console like so:
13+
You can write to the console from a PHP program with the following code:
1414

1515
```php
1616
<?php
1717
echo "text";
1818
```
1919

20-
When you are done, you must run:
20+
The first line tells the PHP to interpret the code following it. It is required before any PHP code is written. Read more here: [http://php.net/manual/en/language.basic-syntax.phptags.php]()
21+
The second line is the instruction to print out some text.
22+
23+
Place the code in to a text file using your favourite text editor, some popular editors are listed below:
24+
25+
* Sublime Text: [https://www.sublimetext.com/]()
26+
* Atom: [https://atom.io/]()
27+
28+
Switch back to the terminal and run your code again with the same command as above:
29+
30+
```sh
31+
$ php program.php
32+
```
33+
34+
You should see the word "text" printed out on the console.
35+
36+
Now you must adapt the code to pass the challenge presented. Remember the challenge was: Write a program that prints the text "Hello World" to the console (stdout).
37+
38+
We have created you a file named `hello-world.php` in your current working directory, feel free to use it!
39+
40+
When you have finished and saved the file you must run the following (substituting program.php to the name of the file you created which contains your code)
2141

2242
```sh
2343
$ {appname} verify program.php

0 commit comments

Comments
 (0)