Download the PHP package bolzer/ts-const-enum without Composer

On this page you can find all versions of the php package bolzer/ts-const-enum. 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 ts-const-enum

Ts-Const-Enum (PHP)

maintained

Description

This tool will transform PHP Scalar-Constants - which are annotated with the provided attributes - to Typescript Constants and generates Typescript Enums from annotated PHP one dimensional constant arrays. This may be useful if you want to reference a value in a condition within your Typescript Code. You can easily import the generated constants. This has many advantages over just stating the value. If the value of the constant changes, your code won't break easily. If you change the name of a php constant the typescript code won't compile unless you changed all occurrences of the old constant name.

This is especially useful if you use alot of JS/TS-Frameworks and do conditionally rendering in regards to values / properties. The Constants are by default prefixed with the declaring class followed by __ and the constant name. You may provide an alias on attribute-level. Keep in mind to have unique names / alias as the constants will land in one file.

Usecase

Before

After

Installation

  1. Require the dependency

  2. Create in your root (where the vendor folder is) dir a config file

  3. Add the following content to the previously created file with the output path.

  4. Take a look at the config class for more config option.
  5. Annotate some constants and arrays in your php code with the provided attributes Constant and Enum

Example

  1. Run the binary of the tool

  2. Start using the constants

What's a makeshift enum in PHP?

Currently there're no enums in PHP. This will change with the release of PHP 8.2. However, those enums need to be transformed to typescript enums too. In the meantime i use constructs like these:

The constant "TYPES" is a makeshift enum. Those constructs will be transformed too. This will translate to the following enum in Typescript


All versions of ts-const-enum with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
symfony/console Version ^5.3
symfony/validator Version ^5.3
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 bolzer/ts-const-enum contains the following files

Loading the files please wait ....