Download the PHP
package vivait/twig-safe-date without Composer
On this page you can find all versions of the php package
vivait/twig-safe-date. It is possible to download/install
these versions without Composer. Possible dependencies are resolved
automatically.
Vendor vivait Package twig-safe-date Short Description A safe date function in twig that will not set null dates to today. License
MIT
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.
Simple filter in twig to help avoid problems with things like: {{ null|date('Y-m-d') }}
There are ways around it using twig - the documentation even states:
If the value passed to the date filter is null, it will return the current date by default. If an empty string is desired instead of the current date, use a ternary operator:
{{ post.published_at is empty ? "" : post.published_at|date("m/d/Y") }}
But often, this is overlooked.
Requirements
PHP >=7.4 or >= 8.2
Twig ^3.0
Installation & Usage
composer require vivait/twig-safe-date
Once required, register the extension with Twig:
Once registered, you can use the filter date to output dates as before, with the change that: null values will get turned into known content (default: -) rather than today's date
The default format is 'F j, Y H:i.' (the same as the core date filter in Twig)
If you wish to change the format of the date, pass it a parameter with your preferred format:
If post.posted_at is null, then by default the filter will output -, if you wish to change this to a different value, pass a new default as the third parameter:
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 vivait/twig-safe-date contains the following files
Loading the files please wait ....
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.