Download the PHP package tedon/kachet without Composer

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

Kachet - Elegant Method-Level Caching for PHP

A Laravel package that provides elegant, method-level caching through a simple proxy pattern. Cache your class methods with zero boilerplate using either PHP attributes or programmatic configuration.

Features

What is Kachet?

Kachet provides a clean, intuitive API for caching method results in your PHP classes. Instead of manually wrapping your methods with cache logic, you can:

  1. Add the Kachetable trait to your class
  2. Configure cacheable methods using attributes or a configuration method
  3. Call cached() when you want to use the cache

Installation

Install via Composer:

For Laravel applications, the service provider will be automatically registered.

Basic Usage

Using PHP Attributes (Recommended)

The simplest way to add caching is using PHP attributes:

Using Programmatic Configuration

If you prefer to configure cache settings in a method, use the cachedMethods() approach:

Advanced Usage

Dynamic Cache Keys with sprintf

Cache keys support sprintf-style placeholders that automatically map to method arguments:

Supported sprintf formats:

Forever Cache (No TTL)

Omit the TTL to cache indefinitely:

Custom Cache Drivers

Specify a custom cache driver (configured in config/cache.php):

Cache Tags

Use tags for easier cache invalidation:

Cache Patterns

Kachet supports different serialization patterns for cached data:

Available patterns:

Caching Null Values

Control whether null results should be cached:

Custom Cache Prefix

Change the default cache key prefix using a class-level attribute:

Configuration Options

Attribute Configuration

When using the #[UseKachet] attribute:

Programmatic Configuration

When using cachedMethods():

Complete Example

Here's a comprehensive example showing multiple caching strategies:

Laravel Facade Usage

Kachet provides a facade for direct cache operations:

How It Works

Kachet uses PHP's magic __call method to intercept method calls on the proxy object:

  1. When you call $obj->cached(), it returns a KachetProxy instance
  2. The proxy holds a reference to your original object
  3. When you call a method on the proxy (e.g., ->findById(1)), the proxy:
    • Looks up the cache configuration for that method
    • Generates a cache key using the method arguments
    • Checks if the result exists in cache
    • If cached: returns the cached value
    • If not cached: calls the original method, caches the result, and returns it

Requirements

Testing

IDE Support & Autocomplete

Kachet fully supports IDE autocomplete for cached methods using PHPDoc annotations. To enable autocomplete in your IDE (PhpStorm, VSCode, etc.), add the following annotation to your class:

With this annotation:

The @method KachetProxy<static> cached() annotation tells the IDE that:

  1. The cached() method returns a KachetProxy instance
  2. The proxy is generic over static (your class type)
  3. Through the @mixin annotation in KachetProxy, the IDE knows the proxy has all your class methods

Note: This annotation is optional - your code will work without it, but adding it significantly improves the development experience.

Best Practices

  1. Use attributes for simple cases - They're cleaner and easier to read
  2. Use programmatic config for complex cases - When you need tags, custom drivers, or patterns
  3. Choose appropriate TTLs - Shorter for frequently changing data, longer for stable data
  4. Use cache tags - Makes cache invalidation easier
  5. Set custom prefixes - Include version numbers for easier cache busting
  6. Cache expensive operations - Database queries, API calls, complex computations
  7. Don't cache everything - Simple getters/setters don't need caching
  8. Add IDE autocomplete annotations - Include @method KachetProxy<static> cached() for better IDE support

Cache Invalidation

Performance Tips

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see the LICENSE file for details.

Author

Pouya Zouravand

Credits

Built with inspiration from Laravel's elegant API design principles and modern PHP best practices.


All versions of kachet with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/cache Version ^10.0|^11.0|^12.0
tedon/tooner Version ^1.0
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 tedon/kachet contains the following files

Loading the files please wait ...