Author Topic: A few questions about composer  (Read 618 times)

0 Members and 1 Guest are viewing this topic.

Offline m0l0ko

  • Peasant
  • *
  • Posts: 129
  • Cookies: -4
    • View Profile
A few questions about composer
« on: August 07, 2014, 04:10:33 am »
I like to set people up websites if they need one but don't know how. I mainly set them up wordpress sites since they don't require any programming skills to manage. To save myself time, I've been learning how to use composer.

Question 1: can you chain two composer.json files together so that after one composer.json file is processed, the next one gets run.

Question 2: can you define variables in composer.json files?

Question 3:

There are a few things I don't understand. Heres a composer.js file I put together:
Code: [Select]
{
    "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/"
        }
    }
}
What are the name and description keys for? In the name key, what is the acme/ part for? Are these keys only for composer.json files that developers add to their packages? Secondly what exactly does the autoload thing do? I want to be  able to put a composer.json file inside a directory, then have it install the application of framework inside that directory but the best I could do was use the installer-paths key to create a folder named by me, then load the wordpress files, as well as the plugins and themes into the places inside my new directory.

I found this online:
Code: [Select]
{
    "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"
}
thats much better since it uses a post installation script that sets up the config.php file for you, but what is this https://raw.github.com/wordpressoncomposer/composer-repository/master/ all about? Its obviously not the official wordpress package hosted on GitHub so what is it, is it a modified package tweaked so it works better with composer? How do you know if you can trust a vendor on a repository like GitHub? Where does this Wordpress\\Composer\\InstallerTasks::wpConfig script come from, is it stored on GitHub as part of the wordpressoncomposer/installer package? On github, there is a composer/installers package, I haven't figure out how to use it but I was wondering if it provides these post installation configuration packages too.