Download the PHP package cognito/wpimporter without Composer

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

WPImporter

This package reads a wordpress export file and formats the posts in a generic way that can be imported into a custom system or CMS.

Installation

Installation is very easy with composer:

composer require cognito/wpimporter

Process

In the Wordpress administration area, go to Tools > Export

Export all content and download the export file.

Transfer the file to the server and parse it by calling

<?php
    $filename = '/the/path/to/the/file.xml';
    $siteurl = 'https://www.sitename.com'; // optional, if left blank it will auto-detect from the xml file (recommended)
    $wpimporter = new \Cognito\WPImporter\WPImporter($filename, $siteurl);

    // Get the posts
    while ($post = $wpimporter->getPost()) {
        var_dump($post);
    }

    // Get the pages
    while ($page = $wpimporter->getPage()) {
        var_dump($page);
    }

    // Get a custom post type, such as faq
    while ($faq = $wpimporter->getPostType('faq')) {
        var_dump($faq);
    }

    // Get the list of images in posts
    $post_img_urls = $wpimporter->postImageList();

    // Get the list of images in pages
    $page_img_urls = $wpimporter->pageImageList();

Image list

The list of images for posts and pages are provided using the postImageList() and pageImageList() functions respectively. This gives a list of urls relative to the root of the siteurl.

The site url is stored in $wpimporter->siteurl so if autodetected this should be used.

All post content has the siteurl stripped so the links are all relative to root rather than including the site url. These images in the list are the relative links as pulled from the posts, so you will have to re-assemble to get the full url to download.

An example would be:

<?php
    $basepath = '/path/to/wwwroot';

    foreach ($post_img_urls as $img_url) {
        // Ensure folder exists
        $folder = $basepath . dirname($img_url);
        if (!file_exists($folder)) {
            mkdir($folder, 0750, true);
        }

        $filename = $folder . '/' . basename($img_url);
        if (file_exists($filename) && filesize($filename) > 0) {
            // Do not overwrite
            continue;
        }

        // Download the file
        $src = $wpimporter->siteurl . $img_url;

        // e.g. using GuzzleHttp
        $client = new \GuzzleHttp\Client();
        $client->request('GET', $src, array(
            'sink' => $filename,
        ));
    }

For larger imports you may prefer to export this as a list and use ajax to give progress to the user.

Featured Images on Posts

To get a list of featured images, call the featuredPostImageList() function.

This returns an array containing the post id and the full url to the image. You should record the post id when importing the posts so that you can download the image into the system and relate it to the imported post.


All versions of wpimporter with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.2
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 cognito/wpimporter contains the following files

Loading the files please wait ....