ziyadsk / dk
Another way to write your php
dev-master
2020-01-13 03:32 UTC
Requires
- php: ^7.2
This package is auto-updated.
Last update: 2025-06-13 15:16:06 UTC
README
Another way to write your php
Installation
Via Composer
composer global require ziyadsk/dk:dev-master
Add the composer bin to your path
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc
Usage
dk [file] [destination]
- If no destination is given the current directory will be the destination.
Features
DK transform more readable code into php
Removed semicolons and dollar signs and openning tags :
name = "John Doe" echo("Hello")
to
<?php $name = "John Doe" ; echo($name); ?>
Shorter syntax for functions and loops :
fn print_100_times(variable){ for(i in {1..100}){ print(variable) } }
to
<?php function print_100_times($variable){ for($i=0 ;$i<=100; $i++){ print($variable); } } ?>
More readable foreach loops :
for(element in my_arr){ print(element) } }
to
<?php foreach($my_arr as $element){ print($element); } ?>
classes , class propreties and interfaces:
class Car : Vehicule [SomeInterface,AnotherInterFace] { static pub name = "Honda" serial_number = "9819020Z0DJLOZEOLD" pub fn start_engine(){} } myCar = new Car() myCar->start_engine()
to
<?php class Car extends Vehicule implements SomeInterface, AnotherInterFace { static $name = "Honda"; private $serial_number = "9819020Z0DJLOZEOLD"; public function start_engine() {} } $myCar = new Car() ; $myCar->start_engine() ; ?>
Editor Support
- VScode extension -> DK