PHPackages                             uthmordar/cardator - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. uthmordar/cardator

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

uthmordar/cardator
==================

parse web pages and generate card object from microdata

038PHP

Since Jul 6Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Uthmordar/cardator)[ Packagist](https://packagist.org/packages/uthmordar/cardator)[ RSS](/packages/uthmordar-cardator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Build Status](https://camo.githubusercontent.com/4839c93ae0851f49276e551fb26055e2aaabc82102ff515e14771eb129f579e6/68747470733a2f2f7472617669732d63692e6f72672f5574686d6f726461722f6361726461746f722e737667)](https://travis-ci.org/Uthmordar/cardator)[![SensioLabsInsight](https://camo.githubusercontent.com/c8dc28b0c9a3ab7aa385d373ba44d689ba1a05016f07f6c32d832b3633657aad/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f34643963386362332d633164612d343730612d393731612d3566303834393337343161632f6d696e692e706e67)](https://insight.sensiolabs.com/projects/4d9c8cb3-c1da-470a-971a-5f08493741ac)

Cardator Package
----------------

[](#cardator-package)

v 1.3.3

Allows web page parsing and gather microdata.

Filtering\\hook possibilities at card instanciation or in PostProcessing.

Output: card collection as hydratated object or json encoded string.

### Base Utilisation:

[](#base-utilisation)

**require a composer dump-autoload --optimize**

```
require_once "vendor/autoload.php";

use Uthmordar\Cardator\Card\CardGenerator;
use Uthmordar\Cardator\Card\CardProcessor;
use Uthmordar\Cardator\Cardator;
use Uthmordar\Cardator\Parser\Parser;

try{
    $cardator=new Cardator(new CardGenerator, new CardProcessor, new Parser);

    /* give only Article type card in output (only has priority over except) */
    $cardator->addOnly('Article');

    /* Thing type card will not be given in output */
    $cardator->addExcept('Thing');

    /* choose url to crawl and extract data, throw RuntimeException if header status 400+ */
    $crawl=$cardator->crawl('http://google.fr');

    /* given closure will be use on given property for all card during the postprocess */
    $cardator->addPostProcessTreatment('my_property_to_filter', function($name, $value){
        // what I want to do
    });
    $cardator->doPostProcess();

    /* get cards as json */
    $cards=$cardator->getCards(true);

    /* get cards as SplObjectStorage collection */
    $cards=$cardator->getCards();
    foreach($cards as $c){
        // do something with cards
    }
}catch(\RuntimeException $e){
    // do something with error
}

```

### Extracted data format :

[](#extracted-data-format-)

This tool crawl webpages searching for [microdata](https://html.spec.whatwg.org/multipage/microdata.html) specifications.

It will also tracks some special attributes and link them to given itemprop:

- dk-raw is an attribute you should use to give informations usable only by developers or robots such as datetime instead of human readable date.
- content attribute could be use on meta tag to mark content hide to user
- value attr could be use to pass numeric value related to tag

You could access some processing informations as follow:

```
    $cardator->getTotalCard(); // Give number of card found
    $cardator->getExecutionTime(); // return crawl duration in s
    $cardator->getStatus(); // return crawler http status

    $cardator->getExecutionData(); // return previous informations as array

```

### Card generation:

[](#card-generation)

You could easily create Card object with:

```
    $cardator->createCard('Article');

```

You could change card library by extending CardGenerator and giving a new library namespacing path as long as you respect interface implementation for cards

### Card properties:

[](#card-properties)

```
    $article=$cardator->createCard('Article');

    // GET
    $name=$article->name;
    $name=$article->name();
    // SET
    $article->name='My Article';
    $article->name('My Article');

    // Existant properties will be hydrated, non-existant property will create an entry in $params array
    $article->params['non-existant'];

    // You could access to all hydrated properties name in an array
    $properties=$article->properties;

    // Card type and card hierarchy
    $cardName=$article->getQualifiedName();
    $cardType=$article->type;

    // Parents : will return an array ['Thing', 'CreativeWork']
    // if more than one parent exist for an item : [['Thing', 'CreativeWork', 'SoftwareApplication'], ['Thing', 'CreativeWork', 'Game']]
    $cardParents=$article->getParents();
    OR
    $cardParents=$article->parents;
    // will return 'Thing\CreativeWork\SoftawareApplication::Thing\CreativeWork\Game'

    // Return the direct parent Name
    $cardDirectParent=$article->getDirectparent();

```

### Data Processing: filter properties value

[](#data-processing-filter-properties-value)

As seen before you could add PostProcessing globally on cardator:

```
    $cardator->addPostProcessTreatment('my_property_to_filter', function($name, $value){
        // what I want to do
    });

```

If you want to create more specific treatment you could also edit the Card in card library as follow:

```
    public function __construct(){
        $this->addFilter('my_property_to_filter', function($name, $value){
            // what I want to do
        });
    }

```

It is also possible to edit your own processing action in Card\\lib\\FilterCard:

```
    $filter=[
        'my_property_to_filter'=>'function to call'
    ];

```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

[![Uthmordar](https://avatars.githubusercontent.com/u/5776424?v=4)](https://github.com/Uthmordar "Uthmordar (92 commits)")

### Embed Badge

![Health badge](/badges/uthmordar-cardator/health.svg)

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

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97513.5M170](/packages/hassankhan-config)[meyfa/php-svg

Read, edit, write, and render SVG files with PHP

54613.9M42](/packages/meyfa-php-svg)

PHPackages © 2026

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