Download the PHP package 1tomany/data-uri without Composer

On this page you can find all versions of the php package 1tomany/data-uri. 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 data-uri

Data URI Parser for PHP

This simple library exposes a single function, OneToMany\DataUri\parse_data() that allows you to easily parse URL or base64 encoded data URIs or valid file paths. During parsing, a temporary, uniquely named file will be stored on the local filesystem and an immutable value object of type OneToMany\DataUri\SmartFile will be created and returned.

By default, instances of the SmartFile object will attempt to delete the temporary file it references upon object destruction. You can change this behavior by setting the $selfDestruct argument of the SmartFile constructor or parse_data() function to false.

Installation

Example

See the parse_example.php file for examples on how to use the parse_data() method.

Testing with MockSmartFile

You may be reluctant to write tests for code that uses the parse_data() function because it interacts with the actual filesystem. For example, if you have a class that takes a SmartFile object and uploads it to a remote storage service, you may not want to actually call parse_data() in your test or instantiate a new SmartFile object since it requires the existence of a file on the local filesystem and will attempt to delete the file when the object is destroyed.

In those instances, you can instantiate the OneToMany\DataUri\MockSmartFile object and use it in place of the SmartFile object. MockSmartFile extends SmartFile, allows you to artificially set any constructor values, and doesn't attempt to delete itself after it is destroyed.

If you do wish to use the parse_data() function, you can write a unit test that does not interact with the filesystem by passing a mocked Symfony\Component\Filesystem\Filesystem object as the last parameter of the parse_data() method in your test. You will need to mock the following methods of the Filesystem class:

An example of the mocked Filesystem class can be found in the ParseDataTest test class in the testParsingFilePathDataRequiresReadableFileToExist() test case.

If you want to take your tests further, you can validate the data is "written" to the temporary file by combining the mocked Filesystem object with a library like mikey179/vfsstream.

Credits

License

The MIT License


All versions of data-uri with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
ext-fileinfo Version *
symfony/filesystem Version ^7.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 1tomany/data-uri contains the following files

Loading the files please wait ....