Chemaclass on v0.9.0
Chemaclass on update-changelog-date-for-0.9
Chemaclass on master
Set release 0.9 in changelog Merge pull request #566 from ph… (compare)
Chemaclass on update-changelog-date-for-0.9
Set release 0.9 in changelog (compare)
Chemaclass on simplify-api-facade
Chemaclass on master
ApiFacade returns a list of Phe… Add test_no_functions_found for… Update and apply phpcs and 1 more (compare)
Chemaclass on simplify-api-facade
Update and apply phpcs (compare)
Chemaclass on allow-underscores-in-decimal-numbers
Chemaclass on master
Allow decimal number with under… Refactor AtomParser applying ex… Update changelog and 5 more (compare)
In my index.php I have to manually switch from two modes. One for production and development and one for development.
public/index.php
<?php
declare(strict_types=1);
$projectRootDir = __DIR__ . '/../';
// Compiles Phel code to PHP on each request and then runs it (Slow).
// require $projectRootDir . 'vendor/autoload.php';
// Phel\Phel::run($projectRootDir, 'app\\boot');
// Runs previously compiled PHP code (Fast).
require_once $projectRootDir . "vendor/autoload.php";
require_once $projectRootDir . "dist/app/boot.php";
How could I tell the application to run in specific mode?
All done. Here is the contact form which is now 100% phel and the website is now on 0.7.0 version. If you disable form validation (add novalidate to form) you can see the server side validation and validation error display in action.
I have solved the issue when using compiled and non-compiled phel code:
composer.json
"scripts": {
"dev:slow": "PHEL_MODE=slow php -S localhost:8000 -t public/",
"dev:fast": "composer compile && PHEL_MODE=fast php -S localhost:8000 -t public/",
"compile": "vendor/bin/phel compile",
}
public/index.php
<?php
declare(strict_types=1);
$phelMode = getenv('PHEL_MODE');
file_put_contents("php://stdout", "\nPhel mode: $phelMode\n");
$projectRootDir = __DIR__ . '/../';
if ($phelMode === 'slow') {
// Compiles Phel code to PHP on each request and then runs it (Slow).
require $projectRootDir . 'vendor/autoload.php';
Phel\Phel::run($projectRootDir, 'app\\boot');
return;
}
// Runs previously compiled PHP code (Fast).
require_once $projectRootDir . "vendor/autoload.php";
require_once $projectRootDir . "dist/app/boot.php";
works great for now.
I did some improvements on the phel snake game. https://github.com/Chemaclass/phel-snake#how-to-play The main change is using the compiled phel code instead of compiling it all the time. Aka: compile once, and play as much as you want.
I added some composer scripts to simplify it even more:
./tools/composer compile
./tools/composer play
./tools/composer start
After the game is compiled, you don't have to compile it again, so using directly the play command will give you a better user experience; the game will load way faster 🚀
# https://github.com/Chemaclass/phel-snake/blob/master/play.php
require_once __DIR__ . "/vendor/autoload.php";
$compiledFile = __DIR__ . "/out/phel_snake/game.php";
if (!file_exists($compiledFile)) {
exit('You have to compile the game first. Try with: `composer compile`');
}
$GLOBALS['argv'][] = 'play';
require_once $compiledFile;
Add __name__ to identify the execution of a script
I will talk about Phel next month, the 10. Oct, about Phel for the Software Crafters Madrid community https://www.meetup.com/es-ES/madswcraft/events/289206891/ I think it will be in Spanish, but if you attend, and you have any question in English, feel free to participate.
My plan is to present the language, the story and motivation behind, and most likely do some live coding 🚀
🚢Release 0.8.0
Yesterday we released version 0.8.0 of Phel. This release adds support for JSON. Read the blog post for more information:
phel compile
but it will be renamed to phel build
in the next version
I prepared last week a scaffolding/skeleton for a web project written in Phel: https://github.com/phel-lang/web-skeleton there you can see the phel-lang/router
project that @jenshaase mentioned above ☝️
It's just an idea with the intention to make it easier to start with the bare minimum and a working example. Feel free to give feedback and suggest changes as you see the need :)