Download the PHP package serhii/goodbye-html without Composer

On this page you can find all versions of the php package serhii/goodbye-html. 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 goodbye-html

Goodbye HTML

Goodbye HTML Total Downloads Latest Stable Version GitHub

A very simple package for separating PHP logic from HTML or any other text. It allows you to insert variables, if/elseif/else statements, loops and ternary operators into any text file and dynamically get parsed content of this file.

Supported PHP versions

What is it for?

This package is useful when you need to separate PHP logic from HTML or any other text. For example if you need to send an email with some dynamic content, you can create a template file with HTML and insert variables, if/elseif/else statements, loops and ternary operators into it. Then you can pass this file to the parser and get parsed content of this file as a string. Then you can use this string as a content of your email.

What is it not for?

This package is not for creating a full-featured template engine. It's just a simple parser that allows you to insert some PHP logic into any text file. It's not for creating a full-featured template engine like Twig, Blade or Latte. If you need a full-featured template engine, you should use one of the mentioned above.

What Goodbye HTML has?

Usage

HTML file content with 2 php variables before parsing it

Parsed HTML to a PHP string

Same example but for WordPress shortcode

Options

The instance of Parser class takes the third argument as a ParserOption enum. You can pass it to the constructor of the Parser class as a third argument. For now, it has only a single options:

ParserOption::PARSE_TEXT

If you pass this option, the parser, instead of getting the content of the provided file path, will parse the provided string. This option is useful when you want to parse a string instead of a file.

Supported types

Types that you can pass to the parser to include them in the html/text file. Note that not all PHP types are supported for know. More types will be added in next releases.

PHP Type Value example
bool true
string 'Is title'
int 24
float 3.1415
null null

Supported prefix operators

Prefix operators are used to change the value of the variable. For example if you have a variable $is_smoking and you want to check if it's false, you can use ! prefix operator to change the value of the variable to false. Or if you have a variable $age and you want to make it negative, you can use - prefix operator to change the value of the variable to negative.

Prefix name Prefix value Example Supported types for prefix
Not ! !true all the types
Minus - -24 int, float

Supported infix operators

Infix operators are used to perform math operations or string concatenation. For example if you have a variable $age and you want to add 1 to it, you can use + infix operator to add 1 to the variable. Or if you have a variable $first_name and you want to concatenate it with $last_name, you can use . infix operator to concatenate these 2 variables.

Operator name Operator literal Example Supported types for prefix
Plus + 3 + 4 int, float
Minus - 5 - 4 int, float
Multiply * 3 * 4 int, float
Divide / 6 / 3 int, float
Modulo % 5 % 2 int, float
Concatenate . 'Hello' . ' world' string
Assigning = {{ $a = 5 }} all the types
Equal == 5 == 5 all the types
Not equal != 5 != 4 all the types
Strong equal === 5 === 5 all the types
Strong not equal !== 5 !== 4 all the types
Greater than > 5 > 4 int, float
Less than < 5 < 4 int, float
Greater or equal >= 5 >= 4 int, float
Less or equal <= 5 <= 4 int, float

All the available syntax in html/text file

Variable

If statements

If/Else statements

If/Else-If/Else statements

Similar to PHP, you can write elseif or else if in the same way.

Ternary operator

Ternary operator is commonly referred to as the conditional operator, inline if/else. An expression a ? b : c evaluates to b if the value of a is true, and otherwise to c. One can read it aloud as "if a then b otherwise c".

Loops

Loop takes 2 integer arguments. The first argument is from what number start looping, and the second argument is where to stop. For example if you start from 1 to 4, it's going to result 4 repeated blocks. Inside each loop you can use $index variable that is going to have a value of current iteration number.

Assigning statements

You can assign values to variables inside your text files using curly braces. For example if you want to assign value 5 to variable $a, you can do it like this {{ $a = 5 }}. You can also use prefix operators to change the value of the variable. For example if you want to assign value false to variable $is_smoking, you can do it like this {{ $is_smoking = !true }}.

Getting started


All versions of goodbye-html with dependencies

PHP Build Version
Package Version
Requires php Version ^8.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 serhii/goodbye-html contains the following files

Loading the files please wait ....