PHPackages                             johnkrovitch/sam - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. johnkrovitch/sam

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

johnkrovitch/sam
================

Simple Assets Manager

v0.1.7(8y ago)16.6k[8 PRs](https://github.com/johnkrovitch/Sam/pulls)1MITPHP

Since Nov 16Pushed 5y ago1 watchersCompare

[ Source](https://github.com/johnkrovitch/Sam)[ Packagist](https://packagist.org/packages/johnkrovitch/sam)[ RSS](/packages/johnkrovitch-sam/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (7)Dependencies (9)Versions (20)Used By (1)

Sam
===

[](#sam)

Simple Assets Manager

Version : 0.1.7

[![Build Status](https://camo.githubusercontent.com/2d11608b1905b506f7849b15425198bdca398e4526b3c59d5585ee8fb2ae0fca/68747470733a2f2f7472617669732d63692e6f72672f6a6f686e6b726f76697463682f53616d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/johnkrovitch/Sam)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/fc8c9f836c3871b58cd8b8c0469f1a2418de69b46bb7d6803af294f390e3193f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a6f686e6b726f76697463682f53616d2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/johnkrovitch/Sam/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/77457cfbbc063b1febcb1dab33df3a862da38af34810026c6a9cc51633064642/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a6f686e6b726f76697463682f53616d2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/johnkrovitch/Sam/?branch=master)[![Build Status](https://camo.githubusercontent.com/7f15d683949cf7ef8ac750331426099fe0aea2526766e3df214ff33b2996a899/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a6f686e6b726f76697463682f53616d2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/johnkrovitch/Sam/build-status/master) [![GuardRails badge](https://camo.githubusercontent.com/07d102ff19e98fde8d2a93f0b818a45e7e791365190b4dbbafffc5aea36481c6/68747470733a2f2f6261646765732e70726f64756374696f6e2e67756172647261696c732e696f2f6a6f686e6b726f76697463682f53616d2e737667)](https://www.guardrails.io)

Sam is your friend. Sam is like you, he does not like handling complicated assets related stuff.

Sam is a Simple Assets Manager to help assets management in PHP Project. You will be able to easily describe where you want your assets to compiled.

Sam was first develop to be used with the SamBundle, but it can be used stand-alone. Using Sam stand-alone require coding your building tasks. With the SamBundle, you will be able to use a more convenient yml configuration syntax.

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

[](#installation)

Using composer :

```
    composer require johnkrovitch/sam

```

Usage
-----

[](#usage)

### Filters

[](#filters)

A filter is a process which transform one or more source files into one or more destination files, using a binary or not. A filter can have options, like the binary path.

Sam a has the following built-in filters for now. More will be added. You can also add your own filter

- Compass filter

The Compass filter will use the [Compass](http://compass-style.org/)binary to transform your ".scss" files into ".css" files.

```
    $configuration = [
        'compass' => [
            // put here the compas binary path. By default it will assume
            // that the binary is loaded in $PATH
            'bin' => 'compass'
        }
    ];
```

- Minify filter

The Minify Filter use the [matthiasmullie/minify](https://github.com/matthiasmullie/minify)library to minify your css and js files. No options are available for now.

- Merge filter

The Merge filter will merge multiple files into one. It allow you to reduce the number of http requests. No options are available for now.

- Copy filter

The Copy filter will copy one or more files into one or more directory.

#### Building your filters

[](#building-your-filters)

In order to use compile your assets, you have to build the filters, using the FilterBuilder. It will check the given configuration and create filters instances according to this configuration.

```

    // enable the filters with default configuration
    $configuration = [
        'compass' => [],
        'merge' => [],
        'minify' => [],
    ];

    // an event dispatcher is required. Some events will be dispatched
    // before the application of each filter
    $eventDispatcher = new EventDispatcher();

    // build tasks using the builder
    $builder = new FilterBuilder($eventDispatcher);

    // filters are build, they can be passed to the runner
    $filters = $builder->build($configuration);
```

### Tasks

[](#tasks)

A Task will apply one or more filters to a list of source files to a directory or a list of destination files. It describe your assets compilation process.

#### Building your tasks

[](#building-your-tasks)

```
    $taskConfigurations = [
        // main.css is just a name, you can put what ever you want
        'main.css' => [
            // this filters will be applied in this order to the destination files
            'filters' => [
                'compass',
                'minify',
                'merge',
            ],
            // sources file to be compiled
            'sources' => [
                'src/MyBundle/Resources/public/css/mycss.css',
                'app/Resources/public/css/mycss.css',
                'css/mycss.css',
                'vendor/a-library/css/lib.css'
            ],
            // all assets will be minified and merged to this file
            'destinations' => [
                'web/css/main.min.css'
            ],
        ],

        'main.js' => [
            'filters' => [
                'compass',
                'minify',
                'merge',
            ],
            'sources' => [
                'css/myjs.js',
                'css/mycss.css',
                'css/mycss.scss',
            ],
            // all assets will be minified and merged to this directory
            'destinations' => [
                'web/css'
            ],
        ]
    ];

    // build tasks using the builder
    $builder = new TaskBuilder();
    $tasks = $builder->build($taskConfigurations);

```

### Running the tasks

[](#running-the-tasks)

Once your filters are configured and build, once your tasks are create, you should run the task using the TaskRunner. A normalizer should be created to normalize file names for the filters.

```
    // used to normalize file names because multiple pattern could be passed
    $normalizer = new Normalizer('/path/to/project_root');

    // used to locate the file
    $locator = new Locator($normalizer);

    // create the runner
    $runner = new TaskRunner(
        $filters,
        $locator,
        // debug
        false
    );

    // run your task
    foreach ($tasks as $task) {
        $runner->run($task);
    }
```

SamBundle
---------

[](#sambundle)

Sam is designed to be used with Symfony and [SamBundle](https://github.com/johnkrovitch/SamBundle)integrate the Sam library with Symfony. It will allow your to put your assets configuration into yaml files. It will ease the integration of vendor js/css library (bootstrap, jquery...) using composer.

You no more have to use BootstrapBundle or jQueryBundle. You just have to require them using composer and easily copy, merge, minify those files with your custom assets.

Issues
------

[](#issues)

Feel free to open an issue if you have a problem using this library.

License
-------

[](#license)

The Sam library is release under the [MIT License](https://opensource.org/licenses/MIT).

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 95.6% 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 ~52 days

Total

8

Last Release

3098d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1a911c960bb7ac86a4ae9c323f1492bc3644f296abc9b370cde0c55407b40a1e?d=identicon)[JohnKrovitch](/maintainers/JohnKrovitch)

---

Top Contributors

[![johnkrovitch](https://avatars.githubusercontent.com/u/1202965?v=4)](https://github.com/johnkrovitch "johnkrovitch (65 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")[![dependabot-support](https://avatars.githubusercontent.com/u/112581971?v=4)](https://github.com/dependabot-support "dependabot-support (1 commits)")[![guardrails[bot]](https://avatars.githubusercontent.com/in/5512?v=4)](https://github.com/guardrails[bot] "guardrails[bot] (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/johnkrovitch-sam/health.svg)

```
[![Health](https://phpackages.com/badges/johnkrovitch-sam/health.svg)](https://phpackages.com/packages/johnkrovitch-sam)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[symfony/maker-bundle

Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.

3.4k111.1M568](/packages/symfony-maker-bundle)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)

PHPackages © 2026

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