Jump to content

Recommended Posts

I like to set up websites for people who don't have the know how to do it themselves, I mainly set them up wordpress sites cuz thats pretty easy for them to modify and maintain themselves. To save myself time, I decided to learn how to do it with Composer (what a brilliant tool that it). Can anyone who uses composer for this kinda thing, can you post your composer.json files here. Also, if anyone can show me a better way of doing things, it'd be much appreciated. Heres the one I made:

{
    "name": "acme/brilliant-wordpress-site",
    "description": "My brilliant WordPress site",
    "repositories":[
        {
            "type":"composer",
            "url":"http://wpackagist.org"
        }
    ],
    "require": {
        "johnpbloch/wordpress": ">=3.8.0",
        "wpackagist-plugin/captcha":">=3.9",
        "wpackagist-plugin/tinymce-advanced":">=4.0.0",
        "wpackagist-plugin/wordpress-importer":"*",
        "wpackagist-theme/hueman":"*",
        "wpackagist-theme/eclipse":"*",
        "wpackagist-theme/raindrops":"*"
    },
    "extra": {
	"installer-paths": {
		"mysite": ["johnpbloch/wordpress"],
		"mysite/wp-content/plugins/{$name}": ["type:wordpress-plugin"],
		"mysite/wp-content/themes/{$name}": ["type:wordpress-theme"]
        }
    },
    "autoload": {
        "psr-0": {
            "Acme": "src/"
        }
    }
}

I think I'm doing this in a silly way though. I read about these composer installer things on github, but I didn't figure out how to use them so instead I used the installer-paths key to make the autoloader put the files in the right place. Heres a composer.json file I found which is better cuz it uses a post installation script:

{
    "require": {
        "wordpress/core": "3.5.2",
        "wordpress/twentytwelve": "1.1",
        "wordpress/akismet": "2.5.7",
        "wordpress/google-sitemap-generator": "3.2.9",
        "wordpress/google-analytics-for-wordpress": "4.3.3",
        "wordpress/wordpress-importer": "0.6.1"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://raw.github.com/wordpressoncomposer/composer-repository/master/"
        },
        {
            "type": "vcs",
            "url": "https://github.com/wordpressoncomposer/installer"
        }
    ],
    "scripts": {
        "post-install-cmd": "Wordpress\\Composer\\InstallerTasks::wpConfig"
    },
    "extra": {
        "wordpress_coredir": "wordpress/core",
        "wordpress_wp_contentdir": "wordpress/wp-content",
        "wordpress_wp_config": {
            "site_url": "http://localhost",
            "db_host": "localhost",
            "db_user": "root",
            "db_pass": "",
            "db_name": "wordpress"
        }
    },
    "minimum-stability": "dev"
}

I'm gonna start using these scripts once I figure out how to use them. Where are the scripts stored? I haven't a clue what this autoload thing is all about either, is it a tool for moving files into the appropriate directories? See how the first file gets wordpress from packagist, and the second one gets it from github. Is there a difference? If I was to add that post-install-cmd key to the first composer.json file, would it still work? In other words, do both repositories contain identical packages.

Packagist is the default directory for packages, that composer reads. It's basically a way of redirecting composer to the location of the actual source. Mostly, people are putting the source for their projects in github, but that is not a requirement for composer to work. Unless over-ridden in the repositories section, composer is going to utilize packagist to figure out where the source for a package is located.

 

However, composer also supports the installation of packages that aren't in packagist and/or github. This is what the repositories section is for -- things that aren't in packagist or are meant to override a default.

 

Composer also builds the autoloader for the php application it is installing, so that the various libraries can be found and autoloaded. You can read more about the concept behind php autoloaders in the namespace era, by googling for PSR-0.

 

As for the composer event hooks like post-install-cmd, take a look at this article: http://www.sitepoint.com/build-automation-with-composer-scripts/

The problem that you are having is that apps like wordpress weren't designed with composer in mind. So, they need special custom scripts.

 

A better solution would be for wordpress to catch up to the rest of the php world and start using composer. Of course, that isn't really likely because their entire application is not modular (nor oop), so it doesn't really fit the "package" mentality.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.