Download the PHP package alingsas-kommun/data-importer without Composer

On this page you can find all versions of the php package alingsas-kommun/data-importer. 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 data-importer

Data Importer & Visualizer

Receive JSON data via REST API, store it in custom database tables, and render it anywhere on your site with PHP templates and shortcodes.


Introduction

Data Importer & Visualizer is a WordPress plugin for teams that need to publish structured, frequently-updated data on a website without building a custom integration from scratch. You define one or more data sources, push JSON to a per-source REST endpoint, and display the records using flexible PHP templates rendered through a simple shortcode.

Typical use cases:


Requirements

Requirement Minimum
WordPress 5.8
PHP 7.4
MySQL / MariaDB any version supported by your WordPress install

No third-party services or external API subscriptions are required. All data is stored in the local WordPress database.


What's Possible

Data sources

REST API import

Templates

Shortcode

Security & operations


Installation

  1. Upload the plugin folder to /wp-content/plugins/.
  2. Activate through Plugins → Installed Plugins in wp-admin.
  3. Go to Settings → Data Importer.
  4. Click Add new source, give it a name and choose an import mode.
  5. Copy the Endpoint URL and the newly created API Key from the API tab immediately, since the plaintext key is only shown once.

Uninstallation

Deactivate and delete the plugin through Plugins → Installed Plugins in wp-admin. The uninstall routine will remove:

Note: Content generated by PHP templates — such as files or external records written by template code — is not tracked by the plugin and will not be removed automatically.


Testing

Run the integration suite from the plugin directory with:

For readable per-test output, use:

To list the discovered tests without running them, use:

The PHPUnit bootstrap loads the local WordPress install, then exercises the plugin's real REST, manual-import, shortcode, safe-mode, and logging flows.


Getting Started

1. Create a data source

Go to Settings → Data Importer → Add new source. Fill in:

2. Push data

Send a POST request with a JSON body to the source endpoint.

A successful import returns:

3. Build a template

Open the source, go to the Template tab and create a new template. Example per-row markup:

Add a wrapper in Wrapper before / Wrapper after:

4. Add the shortcode to a page

With a specific template:


Shortcode Reference

Attribute Default Description
source (first source) Slug of the data source. May be omitted when exactly one source exists.
template (default template) Name of the template to use.
limit 0 (all) Maximum number of records to render.
offset 0 Number of records to skip.
order ASC Database row order when no field sort is active: ASC or DESC.
id 0 Fetch a single record by its database row ID.
sort — Compact multi-sort rules, e.g. firstname|string|asc,surname|string|desc.
sort_key — Comma-separated field keys to sort on. Supports dot-notation for nested fields.
sort_type auto Comma-separated sort types: auto, string, number, or date.
sort_order ASC Comma-separated sort directions.
sort_empty last Comma-separated empty-value positions: first or last.
where_key — Field name to filter on. Supports dot-notation for nested fields, e.g. address.city.
where_op — Comparison operator (see table below).
where_value — Value to compare against.

Supported where_op values

Operator Behaviour
eq Exact match
neq Not equal
contains String contains (case-insensitive)
starts_with String starts with
ends_with String ends with
gt Greater than (numeric)
lt Less than (numeric)

Shortcode examples

Show all active items:

Filter by a nested field:

Paginate — second page of 10:

Sort by first name ascending, then surname descending:

Sort by a nested numeric value and render the top 10:

Single record:


Template Variables

Inside the per-record template, the following PHP variables are available:

Variable Type Description
$vars array Associative array of all top-level fields for the current row.
$record array Alias for $vars — the full record as an associative array.
$record_index int Zero-based index of the current row after filtering, sorting, limit, and offset.
$record_position int One-based position of the current row after filtering, sorting, limit, and offset.
$record_count int Total number of rows being rendered.
$is_first bool true when the current row is the first rendered row.
$is_last bool true when the current row is the last rendered row.

Access fields via $vars:

Conditional rendering:

First, middle, and last row checks:

Optional variable extraction

By default, record fields are only accessible via $vars. You can opt in to also having each top-level key extracted as its own variable ($title, $status, …) using the data_importer_template_extract_vars filter:

Security note: Only enable extraction if you control the shape of all imported records. A record with a key named code, vars, or context can cause subtle or unexpected behaviour in the template scope.

Note: Template code is executed as PHP. Only trusted administrators should be allowed to edit templates. See SECURITY.md.


Import Modes

Mode Behaviour
replace Deletes all existing records for the source, then inserts the new payload. Use for full dataset syncs.
append Inserts incoming records alongside existing ones. Use for log-style or additive feeds.
upsert Inserts new records or updates existing ones matched by one or more key columns you define. Use for syncing keyed datasets without losing data between pushes.

For upsert, set the Update key field in the source settings to a comma-separated list of JSON field names that uniquely identify a record (e.g. id or event_id,date).

Overriding the import mode per request

You can override the source's configured import mode for a single request by adding a mode query parameter to the endpoint URL:

Valid values for mode are replace, append, and upsert. Any other value is rejected with a 400 response. When the parameter is omitted, the mode configured in the source settings is used.


Security

See SECURITY.md for a full OWASP Top 10 mapping and all filter hooks.

Runtime filter hooks

These WordPress filters let you tune security policy without modifying the plugin:

Filter Type Default Description
data_importer_capability string manage_options Capability required to access Data Importer admin and edit templates.
data_importer_enable_php_templates bool true Set to false to disable all PHP template execution globally.
data_importer_safe_mode_active bool — Programmatically force safe mode.
data_importer_max_payload_bytes int 1048576 Maximum accepted request body size in bytes (1 MB).
data_importer_max_records_per_import int 1000 Maximum records accepted in a single import.
data_importer_max_template_bytes int 524288 Maximum template source size in bytes (512 KB).
data_importer_rate_limit_count int 60 Maximum imports allowed per rate-limit window.
data_importer_rate_limit_window int 60 Rate-limit window in seconds.
data_importer_trust_proxy bool false Trust X-Forwarded-For headers for IP resolution (enable behind a known reverse proxy only).
data_importer_require_json_content_type bool true Require Content-Type: application/json on import requests. Set to false to accept other content types.

Rate limiting is best-effort. The built-in limiter uses WordPress transients. Without a persistent object cache (Redis, Memcached) transients are stored in wp_options, which can become a write bottleneck under high traffic. The counter increments are also non-atomic, so concurrent requests may slip past the limit before it is enforced. For production deployments that require reliable rate limiting, enforce limits at the infrastructure layer — an Nginx limit_req directive, a WAF rule, or a reverse-proxy rate limiter will be more accurate and more performant. | data_importer_template_error_details | bool | false | Expose PHP error details in the frontend (enable in development only). | | data_importer_blocked_template_functions | string[] | (see below) | Array of PHP function names that are forbidden inside templates. Add or remove entries to tune the blocklist. | | data_importer_blocked_template_constructs | string[] | (see below) | Array of PHP language constructs that are forbidden inside templates (backticks, include/require family). | | data_importer_template_extract_vars | bool | false | Re-enable legacy extract() behaviour so record keys are available as $name etc. See security note in Template Variables. |

Default blocked functions

The following functions are blocked in templates by default. Use the data_importer_blocked_template_functions filter to add or remove entries:

The callable-accepting functions (call_user_func, array_map, etc.) are blocked because they can invoke arbitrary code when given a user-influenced callable. If a template genuinely needs one of them, remove it via the filter after reviewing how the callable argument is derived.

Default blocked constructs

Language constructs (which are not function calls and cannot be reached by the function blocklist regex) are covered by a separate data_importer_blocked_template_constructs filter:

backticks refers to the backtick shell-exec operator (`command`). The include / require family is blocked because it can execute code from a file path that may be attacker-influenced.

Example — add file_get_contents to the blocklist:

Example — remove a function from the blocklist:

Example — lower the rate limit and disable PHP templates on a staging environment:


Safe Mode

If a broken PHP template causes a fatal error on the front-end:

  1. In the Data Importer admin, click Activate safe mode in the notice bar.
  2. While safe mode is active, no PHP templates are executed on the front-end.
  3. Open the Template tab, fix the template, and save.
  4. Click Deactivate safe mode to restore normal rendering.

Safe mode can also be forced programmatically:

Or via filter:

When either the constant or a filter is in effect, the Data Importer admin shows an override in effect notice and hides the Disable Safe Mode button, so administrators understand the UI toggle is currently inert.


Frequently Asked Questions

Can I push a single object instead of an array?

Yes. Both {} and [{}, {}] are accepted. A single object is treated as one record.

Can I restrict which servers are allowed to import?

Yes. In the source API tab, enter a comma-separated list of allowed IP addresses. Leave empty to allow any IP.

How do I retrieve the available field names for a source?

Authenticated admin users can call:

This returns the unique field names found across all stored records.

Can I test an import without an external system?

Yes. Go to the source's Manual tab, paste a JSON payload, and click Import. The result is shown in the Log tab under Import Log.

How do I use multiple templates for the same source?

Create additional templates in the Template tab. Reference them by name in the shortcode:

What happens to old data when I push a new payload in replace mode?

All existing records for that source are deleted before the new records are inserted. Use append or upsert mode if you need to preserve existing data.

Can I use different import modes without changing the source settings?

Yes. Add a mode query parameter to the endpoint URL to override the configured mode for that single request. This is useful when the same source needs different import strategies on different schedules — for example a full replace once a week and an upsert every weekday:

The source settings are not changed; the override only applies to that request.


All versions of data-importer with dependencies

PHP Build Version
Package Version
No informations.
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 alingsas-kommun/data-importer contains the following files

Loading the files please wait ...