-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7c83d8
commit f8f7655
Showing
1 changed file
with
10 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,48 +30,13 @@ cd hello-world | |
composer init | ||
``` | ||
|
||
Composer will ask a bunch of questions that can be answered as in the following example. | ||
|
||
``` | ||
Welcome to the Composer config generator | ||
This command will guide you through creating your composer.json config. | ||
Package name (<vendor>/<name>): phel-lang/hello-world | ||
Description []: | ||
Author [Your Name <[email protected]>, n to skip]: | ||
Minimum Stability []: | ||
Package Type (e.g. library, project, metapackage, composer-plugin) []: project | ||
License []: | ||
Define your dependencies. | ||
Would you like to define your dependencies (require) interactively [yes]? no | ||
Would you like to define your dev dependencies (require-dev) interactively [yes]? no | ||
{ | ||
"name": "phel-lang/hello-world", | ||
"type": "project", | ||
"authors": [ | ||
{ | ||
"name": "Your Name", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": {} | ||
} | ||
Do you confirm generation [yes]? yes | ||
``` | ||
|
||
Next, require Phel as a dependency. | ||
|
||
```bash | ||
# Require and install Phel | ||
composer require phel-lang/phel-lang | ||
``` | ||
|
||
First, create a phel config file, called `phel-config.php` in the root of the project: | ||
Optionally, create the "phel config file", named `phel-config.php` in the root of the project: | ||
|
||
```php | ||
<?php | ||
|
@@ -83,17 +48,17 @@ return (new \Phel\Config\PhelConfig()) | |
|
||
> Read the docs for [Configuration](/documentation/configuration) to see all available configuration options for Phel. | ||
Then, create a new directory `src` with a file `boot.phel` inside this directory. | ||
Then, create a new directory `src` with a file `main.phel` inside this directory. | ||
|
||
```bash | ||
mkdir src | ||
``` | ||
|
||
The file `boot.phel` contains the actual code of the project. It defines the namespace and prints "Hello, World!". | ||
The file `main.phel` contains the actual code of the project. It defines the namespace and prints "Hello, World!". | ||
|
||
```phel | ||
# in src/boot.phel | ||
(ns hello-world\boot) | ||
# inside `src/main.phel` | ||
(ns hello-world\main) | ||
(println "Hello, World!") | ||
``` | ||
|
@@ -109,11 +74,11 @@ There are two ways to run the code: from the command line and with a PHP Server. | |
Code can be executed from the command line by calling the `vendor/bin/phel run` command, followed by the file path or namespace: | ||
|
||
```bash | ||
vendor/bin/phel run src/boot.phel | ||
vendor/bin/phel run src/main.phel | ||
# or | ||
vendor/bin/phel run hello-world\\boot | ||
vendor/bin/phel run hello-world\\main | ||
# or | ||
vendor/bin/phel run "hello-world\boot" | ||
vendor/bin/phel run "hello-world\main" | ||
``` | ||
|
||
The output will be: | ||
|
@@ -127,7 +92,7 @@ Hello, World! | |
|
||
> Check the [web-skeleton project on GitHub](https://github.com/phel-lang/web-skeleton). | ||
The file `index.php` will be executed by the PHP Server. It initializes the Phel Runtime and loads the namespace from the `boot.phel` file described above, to start the application. | ||
The file `index.php` will be executed by the PHP Server. It initializes the Phel Runtime and loads the namespace from the `main.phel` file described above, to start the application. | ||
|
||
```php | ||
// src/index.php | ||
|
@@ -139,7 +104,7 @@ $projectRootDir = __DIR__ . '/../'; | |
|
||
require $projectRootDir . 'vendor/autoload.php'; | ||
|
||
Phel::run($projectRootDir, 'hello-world\\boot'); | ||
Phel::run($projectRootDir, 'hello-world\\main'); | ||
``` | ||
|
||
The PHP Server can now be started. | ||
|