Download the PHP package webzille/cssparser without Composer

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

CssParser

Parse CSS file into a simple abstract syntax tree (AST) data structure.

About Webzille / CssParser

This package parses a CSS file and puts each construct in it's own object in the order as they appear in the CSS file. The AST structure is fairly simple at the moment and their plenty room for improvements.

Installation

To begin parsing CSS files with this packages you need to run the following command VIA composer.

Usage

Using the parser is quite simple. To parse a CSS file and get the generated AST data structure back (AKA nodes).

Then to render the CSS you could render it with the help of the format class. If you don't use it, it would use the default format.

That example sets the same indentation and newline characters as are the defaults if you don't use the format object.

If you want minified CSS, instead of setting an empty string as indent and newline, you could simply use the minify() method which takes an optional boolean argument as it's value to make the minification dynamic (wether it's based on specific conditions or user input).

At the moment, minified CSS is simply the entire CSS in one line.

Factory

The factory class is provided to give easy access to all classes available in the package to allow easy one-liners without instantiating objects to variables unnecessarily.

Searching

The search utility class is provided to help searching through the CSS AST Data Structure in various ways. You could search for a specific selector, property, property / value pair or other various methods. To use the search utility you could either instantiate the class yourself, or use the static search factory method to get the instance and do your search in one line.

If you use the static factory method, you could easily chain other methods to it without having to dirty up your code with either additional lines or using parentheses.

The following search methods are included at the moment:

You get your results through the method results() and if you don't want to mingle results between various search queries, you would need to clear the results between searches VIA the clearResults() method

For a more comprehensive example of searching, you may check out the searchDemo.php provided.

Optimization

This package also provides an optimization utility class you may use to optimize the parsed CSS data structure which you could later render as minified or pretty CSS. Just like the search utility class, you could initiate the class directly or by using the static factory method for the same reasons as the search utility class.

The following optimization options it offers at the moment.

If you want / need to, you may chain all (or as much as you need) the optimizing methods together to have them all optimize your CSS before rendering. (As I've done in demo.php).

Every method logs every change they make which you could retrieve VIA the getModified() method. You could also clear the log VIA the clearModified() method between optimizing methods if you want to see what each method does without the logs from other methods cluttering up the log.

The line numbers of every logged modification are relative to the original parsed CSS file and not the rendered CSS.

For a more comprehensive optimization example, you may check out the optimizeDemo.php provided.

Contributing

Contributions to the Webzille CSS Parser are welcome! Please ensure that you submit pull requests to the development branch.

License

This project is licensed under the MIT License - see the LICENSE file for details.


All versions of cssparser with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
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 webzille/cssparser contains the following files

Loading the files please wait ....