Download the PHP package aftermarketpl/php2js without Composer

On this page you can find all versions of the php package aftermarketpl/php2js. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php2js

aftermarketpl-php2js

This project aims to create a fairly complete PHP to JavaScript transpiler.

Its primary purpose is to aid internal development of AfterMarket.pl, but since it may also be of an interest to the general public, it is released under Apache license and available as a composer package.

Project aims

The most important design goals of the converter are as follows:

Limitations

Since it is not a general purpose transpiler, there are limits on what the transpiler accepts. If it encounters PHP code which it cannot transpile properly, it will normally throw an exception, although in some edge cases it can produce JavaScript code from PHP code it should theoretically not support; such code is not guaranteed to run properly.

At this point the transpiler will convert most of functional PHP code, which does not contain any class definitions or usage. Thus, the following sample PHP code will translate nicely to JavaScript:

The resulting JavaScript is:

The produced code is easily readable by humans, and contains only minimum overhead.

PHP syntax not yet accepted:

The following PHP constructs are not supported at the moment, and will likely not be supported at all, although we may implement some of them if time permits:

Computed variable and function names

Seriously, you really shouldn't be doing this anyway.

String subscripting with brackets

This mainly stems from the fact that the transpiler does not know whether the variable is an array or a string. With PHP 7 type hinting, this may be improved in the future if the type of the variable can be deduced.

Some array operations

Again, with the plus operator the transpiler does not know if the variable is a numeric or an array. PHP 7 type hinting may improve this as well.

Some binary and assigmment operators

Some of these operators may be supported with ugly JavaScript, so the situation may improve.

Variable references

They cannot be easily reproduced in JavaScript in general.

Multi-level break and continue

They cannot be easily reproduced in JavaScript in general.

Classes and exceptions:

They are at the moment not supported at all, but we intend to work on them so you can expect a fairly broad support in the future.

PHP standard library

PHP is not just a language; it is also a quite extensive library of standard functions such as substr() or preg_match(). We intend to implement a broad range of these functions, but since it requires a significant effort, it will take us some time to get there. Some functions will never be supported because they make no sense in a browser environment (such as file I/O). Some functions require too much effort compared to expected gain, so we may choose not to implement them (although you can do it, and we will gladly incpororate your code!). In general, we want to focus on string and array functions first because that's what we use in our own code.

As a teaser, a few string functions are implemented already, so you can try code such as this:

The resulting JavaScript will be:


All versions of php2js with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
nikic/php-parser Version >=4.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package aftermarketpl/php2js contains the following files

Loading the files please wait ....