faslatam / jsphp
Give your PHP projects a touch of JavaScript with JSPHP! 🚀
Requires
- php: ^7.1 || ^8
- symfony/polyfill-php73: ^1.28
- symfony/polyfill-php80: ^1.28
- symfony/polyfill-php81: ^1.28
Requires (Dev)
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^1.4
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-strict-rules: ^1.1
- phpunit/phpunit: ^7.5
Suggests
- phpstan/phpstan: PHP Static Analyzer
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.