faslatam/jsphp

Give your PHP projects a touch of JavaScript with JSPHP! 🚀

v0.4 2024-04-13 00:13 UTC

This package is auto-updated.

Last update: 2024-10-29 16:57:15 UTC


README

Nota: Esta documentación está siendo traducida: > Ver en español

📚 JSPHP is a powerful PHP library that provides a set of classes designed to mimic the behavior of JavaScript's primitive classes such as Number, String, and more.

🎯 With JSPHP, PHP developers can leverage familiar JavaScript concepts and functionalities in their PHP projects. 🌈

This library aims to bridge the gap between JavaScript and PHP, allowing developers to write cleaner and more efficient code.

✨ Whether you're a PHP developer looking to explore JavaScript-like features or a JavaScript developer working with PHP, JSPHP is the perfect tool to enhance your development experience. 💪

Give your PHP projects a touch of JavaScript with JSPHP! 🚀

Requirements

Installation

🚀 Getting started with using JSPHP is super easy! Just follow these simple steps:

1- First, install JSPHP using composer:

composer require faslatam/jsphp

2. Include the composer autoloader:

<?php

require '/path/to/vendor/autoload.php';

# Finally, you're all set! You can now start using JSPHP in your projects.

$name = String('foo');
echo $name->toUpperCase(); # Output: FOO

$user = JSON::parse('{ "id": 1, "name": "foo" }');
echo $user->name; # Output: foo

$colors = JSArray(['red', 'purple', 'black']);
$colors->forEach(function (?string $color): void {
  echo "I like the color $color\n";
});

echo "\ncolors = $colors";

/* Output:
----------
I like the color red
I like the color purple
I like the color black

colors = red,purple,black
 */

Components

JSPHP is divided in components that are equivalent to JS classes. Some components are under development, feel free to contribute adding extra functionalities.

> See documentation