PHPackages                             responsive-sk/vite - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. responsive-sk/vite

ActiveLibrary[Templating &amp; Views](/categories/templating)

responsive-sk/vite
==================

Vite integration for Slim 4 framework

1.3.0(1y ago)011MITPHPPHP ^7.4|^8.0

Since Apr 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/responsive-sk/slim4-vite)[ Packagist](https://packagist.org/packages/responsive-sk/vite)[ Docs](https://github.com/responsive-sk/slim4-vite)[ RSS](/packages/responsive-sk-vite/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (4)Used By (0)

ResponsiveSk Vite Integration
=============================

[](#responsivesk-vite-integration)

A simple and lightweight integration of Vite with Slim 4 framework.

Installation
------------

[](#installation)

```
composer require responsive-sk/vite
```

Usage
-----

[](#usage)

### Register the service in your container

[](#register-the-service-in-your-container)

```
use ResponsiveSk\Vite\ViteService;
use ResponsiveSk\Vite\TwigExtension;
use Slim4\Root\PathsInterface;

// In your container definitions
$container->set(ViteService::class, function ($container) {
    $paths = $container->get(PathsInterface::class);
    $isDev = $_ENV['APP_ENV'] === 'development';

    // Basic configuration
    return new ViteService($paths, 'build', $isDev);

    // Advanced configuration with custom asset directories
    /*
    return new ViteService(
        $paths,
        'build',
        $isDev,
        'http://localhost:5173',
        [
            'images' => 'assets/images',
            'fonts' => 'assets/fonts',
        ]
    );
    */
});

// Register Twig extension
$container->extend(Twig::class, function ($twig, $container) {
    $viteService = $container->get(ViteService::class);
    $twig->addExtension(new TwigExtension($viteService));
    return $twig;
});
```

### Use in Twig templates

[](#use-in-twig-templates)

```
{# Load CSS for an entry point #}
{{ vite_entry_link_tags('css') }}

{# Load JavaScript for an entry point #}
{{ vite_entry_script_tags('app') }}

{# Get URL for an asset #}

{# Get URL for an image #}

{# Get URL for an image with custom resource path #}

{# Get URL for an image with custom resource path and placeholder (fallback if image not found) #}

{# Handle missing images gracefully #}
{% set image_url = vite_image('missing.jpg') %}
{% if image_url %}

{% else %}
    Image not found
{% endif %}

{# Get URL for a font #}

    @font-face {
        font-family: 'CustomFont';
        src: url('{{ vite_font('custom.woff2') }}') format('woff2');
    }

```

Configuration
-------------

[](#configuration)

The `ViteService` constructor accepts the following parameters:

- `PathsInterface $paths`: The paths service from slim4/root
- `string $buildDirectory = 'build'`: The build directory relative to public path
- `bool $isDev = false`: Whether to use dev server
- `string $devServerUrl = 'http://localhost:5173'`: Dev server URL
- `array $assetDirectories = ['images' => 'assets/images', 'fonts' => 'assets/fonts']`: Directories where assets are stored

Available Methods
-----------------

[](#available-methods)

### ViteService

[](#viteservice)

- `asset(string $entry): string` - Get the path to an asset
- `entryLinkTags(string $entry): string` - Generate link tags for CSS files from an entry
- `entryScriptTags(string $entry): string` - Generate script tags for JS files from an entry
- `image(string $path, string $resourcePath = 'resources/images', ?string $placeholder = null): ?string` - Get the path to an image, returns null if image not found and no placeholder specified
- `font(string $path): string` - Get the path to a font
- `getManifest(): array` - Get the raw manifest data

### TwigExtension

[](#twigextension)

- `vite_asset(string $entry): string` - Get the path to an asset
- `vite_entry_link_tags(string $entry): string` - Generate link tags for CSS files from an entry
- `vite_entry_script_tags(string $entry): string` - Generate script tags for JS files from an entry
- `vite_image(string $path, string $resourcePath = 'resources/images', ?string $placeholder = null): ?string` - Get the path to an image, returns null if image not found and no placeholder specified
- `vite_font(string $path): string` - Get the path to a font
- `vite_css(string $entry): string` - Alias for vite\_entry\_link\_tags (legacy)
- `vite_js(string $entry): string` - Alias for vite\_entry\_script\_tags (legacy)

License
-------

[](#license)

MIT

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance48

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

3

Last Release

382d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a9ca94d5516a8f930325df47de8418a33caf484280105d108a693533c73d4699?d=identicon)[evan70](/maintainers/evan70)

---

Top Contributors

[![evan70](https://avatars.githubusercontent.com/u/67433?v=4)](https://github.com/evan70 "evan70 (8 commits)")

---

Tags

twigslimbladeviteassetsfrontendlatteplatesslim4

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/responsive-sk-vite/health.svg)

```
[![Health](https://phpackages.com/badges/responsive-sk-vite/health.svg)](https://phpackages.com/packages/responsive-sk-vite)
```

###  Alternatives

[twig/extra-bundle

A Symfony bundle for extra Twig extensions

91492.0M315](/packages/twig-extra-bundle)[twig/intl-extra

A Twig extension for Intl

36763.2M221](/packages/twig-intl-extra)[twig/string-extra

A Twig extension for Symfony String

22046.0M133](/packages/twig-string-extra)[symfony/ux-twig-component

Twig components for Symfony

21914.8M162](/packages/symfony-ux-twig-component)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
