Skip to content

Commit

Permalink
simplify getting started
Browse files Browse the repository at this point in the history
  • Loading branch information
Chemaclass committed May 24, 2024
1 parent d7c83d8 commit f8f7655
Showing 1 changed file with 10 additions and 45 deletions.
55 changes: 10 additions & 45 deletions content/documentation/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <your.name@domain.com>, 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": "your.name@domain.com"
}
],
"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
Expand All @@ -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!")
```
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit f8f7655

Please sign in to comment.