Download the PHP package flat3/babel-blade without Composer

On this page you can find all versions of the php package flat3/babel-blade. 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 babel-blade

Babel compiler for Laravel Blade

This package allows you to safely write modern, inline JavaScript in blade templates. Compilation only happens at Blade template caching time, so has no effect on production performance.

Installation

To install the package via composer:

composer require flat3/babel-blade

The compiler expects a nodejs install on the same PATH that is being used by your PHP interpreter.

You must install babel (and normally the env preset) in your Laravel project:

npm install --dev @babel/core @babel/preset-env

The compiler looks for a babel configuration starting from the view root (normally resources/views) and searching upwards. You can therefore use any existing babel configuration file in your project, or you can create one in resources/views that will only be used for babel-blade.

For example at resources/views/.babelrc.json

Usage

Babel-blade looks for script blocks that use the string literal <script type="text/babel"> so no other javascript or script block will be modified.

This script block using the babel config above:

will be transformed at compile time into:

Laravel Vapor

The Vapor build process clears the view caches and builds templates on first load server-side. This is incompatible with babel-blade, since nodejs etc. will not be available.

To work around this, invoke the build as part of the vapor deploy process as BABEL_BLADE_CACHE=1 php artisan view:cache. This will compile the templates locally into blade files in the view root, and add @includes to pull the compiled code in during compilation.

Polyfills

Babel implements async/await using generators, which need to be polyfilled on older platforms. Without the polyfill you'll see the error:

To solve this you can include an additional script tag that includes the polyfill, for example:

Blade directives

Because babel-blade runs early in the compilation process, directives such as @json($src) haven't been parsed yet and will be passed to Babel as they are.

You will then get failures such as as Babel tries to parse @json.

There is likely not a solution to this due to the order of execution in blade, instead use the style "{{$src}}" with appropriate escaping.

License

Copyright © Chris Lloyd

Flat3 babel-blade is open-sourced software licensed under the [MIT license]


All versions of babel-blade with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0
symfony/process Version ^5.2
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 flat3/babel-blade contains the following files

Loading the files please wait ...