Loading...
 

Composer

Please also see:
A high level overview of how Tiki uses Composer

. Introduction

If you are getting an error about Composer not being set up, run

This will set permissions and run Composer
sh setup.sh


If you are having issues, delete your “vendor” directory and run sh setup.sh again.

If one of the packages is not working for you (ex.: won’t download, or some other error) and you don’t need it for your Tiki, just:

  1. Delete the vendor directory (Composer will just recreate)
  2. Remove the line for that package from composer.json
  3. Run ‘php temp/composer.phar --no-dev update’ (This will update composer.lock, note the use of --no-dev as recently (end of 2015) composer now defaults to include dev packages)
  4. Run ‘sh setup.sh’ (This will re-run Composer)


Composer is a dependency management tool for PHP. It is being used as a replacement for Subversion Externals from Tiki11.

Composer maintains a list of dependencies using the composer.json file and stores downloaded content into the vendor folder. Additionally, an autoload script is being generated to avoid handling the various paths generated.

Available packages can be found on Packagist, the companion website.


1.2. Description of various vendor folders

Tiki17+

  • vendor: for your libs managed in composer.json
  • vendor_bundled: libs bundled in Tiki. List is at vendor_bunded/composer.json
  • vendor_custom: for custom libs, usually manually uploaded (if you need it)
  • vendor_extra: for libs not yet managed by Composer

Until Tiki16

  • vendor: libs bundled in Tiki. List is at composer.json
  • vendor_custom: for custom libs, usually manually uploaded (if you need it)
  • vendor_extra: for libs not yet managed by Composer

1.3. Production vs Development environments

1.3.1. Production Environment


The release process has been updated. Installation from built packages should not be affected.

Installations from Subversion need to be considered as development environments.

1.3.2. Development Environment


The composer install process has been added to the setup.sh script. Running it as usual should ensure composer is downloaded and executed.

Keep in mind this is a fairly new addition to the process. Some environments may run into issues until it is stabilized.

If your environment does not provide all of the tools required to automatically set-up the dependencies, you will need to perform a few steps manually.

  1. Download composer and store composer.phar in the temp/ folder:
    • wget https://getcomposer.org/composer.phar -P temp
  2. Run composer:
    • php temp/composer.phar install

Note for Windows users

[+]

1.4. Managing dependencies

1.4.1. How to change composer.json packages and dependencies

When you need to use a certain composer package not available yet in composer.json file or update the tiki dependencies on existing packages, please run the following command after updating composer.json:

./composer.phar update --prefer-dist


This will generate a new composer.lock file. You can review the differences with the old one via `svn diff`. If you notice a `dist.url` in packages array that is not pointing to composer.tiki.org, this means that satis configuration of composer.tiki.org should be updated. Please open `doc/devtools/satis.json` and add/change the package requirement in `require` section at the bottom of the file. Make sure every package composer.lock file tries to load from an external url is properly required in satis.json.

Then, you should be able to commit satis.json and let composer.tiki.org update which should happen within 10 minutes. After composer.tiki.org is updated, you should run again:

./composer.phar update --prefer-dist


and compare the differences of composer.lock file with svn. You should now not see any external urls in `dist.url` sections of packages array. Then, you can safely commit composer.json and composer.lock files.

Important: when changing satis.json, be sure to not update existing package requirements in a way that old packages are excluded. Older tiki versions require older package versions and we should be careful when updating package requirement to keep the old package still accessible. This implies the usage of ~ and >= specifiers instead of simply increasing the version number.

1.4.2. Adding dependencies

Adding dependencies is easy:

  1. Lookup the package name on Packagist first. If that doesn’t exist, look for a zip or svn/github repo.
  2. Add to doc/devtools/satis.json in Tiki trunk. Learn more about Satis here. Look at existing examples for the format. See also http://getcomposer.org/doc/04-schema.md.
    • Note: Before moving onto the next step, ensure that composer.tiki.org has successfully added your package. composer.tiki.org is updated every X hours from trunk
  3. Add the entry to the composer.json file for your branch by specifying the full release version.
    • Composer allows for development branches and unstable packages. However, ideally, Tiki should only use released versions of software.
    • Non-exact version numbers could cause conflicts. We don’t want that.
  4. If you are migrating a past external, kill it from the external list. All SVN externals are gone in Tiki11
  5. Clear the Composer cache as follows:
    rm -R ~/.composer/cache/
  6. Run: php temp/composer.phar update --prefer-dist
  7. Test and develop
  8. Commit your changes in composer.json and composer.lock

1.4.3. Updating dependencies

Similar to adding dependencies.

  1. Add to doc/devtools/satis.json in Tiki trunk (but don’t remove the old one if it’s still needed for a previous Tiki version)
    • composer.tiki.org is updated every X hours from trunk
  2. Update the version number in composer.json and run php temp/composer.phar update --prefer-dist (This will update composer.lock)
  3. Note: if you are going to commit the lock file back to Tiki then run update without the --no-dev option so the require-dev packages are included


http://versioneye.wordpress.com/2013/03/25/minimum-stability/

1.4.3.1. Suppressing the Ambiguous Class Warning

You can add a pipe command to the normal composer.phar commands to hide all the annoying “Ambiguous class resolution” warnings that some of the old third party libraries generate during the autoload files generation, using:

php temp/composer.phar --no-dev install 2>&1 | sed '/Warning: Ambiguous class resolution/d'

or after changing composer.json use:

php temp/composer.phar update -d vendor_bundled --prefer-dist 2>&1 | sed '/Warning: Ambiguous class resolution/d'

    • Note: the addition of the -d vendor_bundled parameter for Tiki 17+ only

1.4.4. Patching dependencies

cweagans/composer-patches was added in Tiki17 (and later enhanced). Although we always want to solve the issue upstream, sometimes, a patch needs to be maintained until things are sorted out.

Here are examples of usage: https://sourceforge.net/p/tikiwiki/code/HEAD/tree//trunk/installer/composer-patches/composer-patches.json

This requires the patch utility and we are coordinating with upstream to do everything in PHP.

1.4.5. Being aware of outdated dependencies

1.5. Troubleshooting Tips

Composer is used for many PHP projects. If you have a general problem with Composer on your setup, first make sure it works outside of Tiki. Then once that works, try with Tiki to determine if the issue is specific to Tiki’s implementation. If you discover dependencies to use Composer, please add to the Composer section of tiki-check.php

1.5.2. Within Tiki

  1. Run Composer in Tiki
    sh setup.sh
  2. Test within Tiki
    php temp/composer.phar diagnose

1.5.3. Test outside Tiki

  1. Get Composer
    http://getcomposer.org/download/
  2. Run diagnose
    php composer.phar diagnose
  3. Try to install Symfony:
    http://symfony.com/doc/current/book/installation.html#option-1-composer

1.5.4. Runtime Exception

If you still get a RuntimeException, on downloading Zend, try:

php temp/composer.phar --no-dev update bombayworks/zendframework1

or

composer update --prefer-dist bombayworks/zendframework1

1.5.5. Uncaught exception

If you’re getting an error message that starts with Fatal error: Uncaught exception ‘ErrorException’ try using php-cli temp/composer.phar update instead of php temp/composer.phar update.

Try also to assign permission recursive manually (-+chown+-) of the entire Tiki directory to web user:web group so the Composer can download files and proceed.

1.5.6. Corrupted Download

If you got this error message:

The download is corrupted (phar "/var/www/sites/yourwebsitepath/html/temp/composer-temp.phar" has a broken signature).
Please re-run the self-update command to try again.


Doing an “update” won’t solve the issue, however re-installing will:

php temp/composer.phar install

(thanks to Jonny)

1.5.7. Download Failures

System admins may try to run “setup.sh” as “root”. This is a bad idea. Downloading composer files under root have great chance to fail due to permission error. If downloading keeps failing, try these steps:

  1. Delete temp/composer.phar
  2. Clear the Composer cache as follows:
    rm -R ~/.composer/cache/
  3. Retry using another user than root or try:
    sudo sh setup.sh

1.5.8. PHP version used on OSX (may be applicable for WAMP on win)

The php version installed with Mac OSX may be different from the one you use with your dev environment (Brew, MacPorts, MAMP or other?). Changes are it is not the one you use on your local. The script setup.sh will try to determine one or several path to check if version and extensions installed are up to date with composer before running it. It may fell to find the path of the php you are using with MAMP (or MAMP Pro). You can then edit or create a file t ~/.bash_profile and add the follwing:

export PATH=/Applications/MAMP/bin/php/PHP_VERSION_YOU_USE/bin:$PATH

Save and restart your terminal.

1.5.9. Error after switching from a previous branch (Ie switching from 16x to 17x)

When switching from a branch to a newer one some error caused by changes in the way Tiki set or handle Composer may occurs.
You may have to delete caches or some files from previous install.

IE:

Fatal error: Uncaught exception 'Symfony\Component\DependencyInjection\Exception\InvalidArgumentException' with message 'You cannot set service "service_container".'

Is solved by deleting : temp/cache/container.php

1.6. Bluehost

If you are on Bluehost, please see: Bluehost

1.7. Composer on Shared Hosts

Shared web hosting services that offer a choice of different PHP versions may require additional configuration in order to apply the chosen PHP version when running Composer through shell. This happens when shell uses a default PHP version even when phpinfo within Tiki shows the chosen version (the version used in shell can be checked by typing php -v). This can cause Composer to not run if the default version is older than the minimum required version. The way to correct it is to set the path to the right PHP version in a ~/.bashrc file in your home directory. Below are a couple of examples:

1.7.1.1. Set PATH variable (this worked with HostGator)

  1. Modify (or create) your ~/.bashrc file to prepend the correct path to the PHP file you want to use. For example, if the PHP executable file is at /opt/php55/bin/php, you would add the following command:
    export PATH=/opt/php55/bin:$PATH;
  2. Then type source ~/.bashrc in shell for the change to take effect before running composer or sh setup.sh

1.7.1.2. Use Full PHP Path to Run Composer Directly

This is a little hacky, but if nothing else is working, instead of running composer through sh setup.sh, composer can be run directly using the specific PHP path you desire, for example:
/usr/local/php56/bin/php temp/composer.phar --no-dev update

1.8. Composer.tiki.org

  • composer.tiki.org fixed by running Satis
  • Could extraneous files like docs in libs be deleted there (and thus, Tiki sites just get the clean packages)? Yes, there is lib/core/Tiki/Composer/CleanVendors.php
  • Find a solution for versions Done
  • use https when possible done
  • As part of the release process, have a way to check Composer packages vs original code Added to How to release

1.8.1. To flush out an incorrect package on composer.tiki.org

If you happen (as I did Jonny Bradley ) to commit a mistake in satis.json, i.e. link to the wrong zip file for instance as corrected in {commit id=54048}, composer.tiki.org will continue to serve up the wrong file until that package is updated again, so here’s how to fix it.

  • First get a friendly member of the Infrastructure Team with some spare time to help :-)
  • They will need to remove the offending package file and it’s cached copy, then run the satis rebuild script, here is an example with the chosen zip above:
cd /var/local/composer.tiki.org/bin/satis/
rm /var/local/composer.tiki.org/www/dist/jquery-plugins-chosen-1.3.0.zip
rm  ~/.composer/cache/files/jquery/plugins/chosen/1.3.0.0-1.3.0.zip -- if it exists
mv satis.json.prev satis.json.prev.bak -- reset for the satis build script
/etc/cron.hourly/qualityupdate -- contains the satis/composer build commands as well as the code.tiki.org script

1.9. Other notes

2013-07-11 topics to discuss with Nils

LP & Marc will see Nils at http://www.phpquebec.org/content/composer-project-dependency-management-php and we’ll discuss with him:

1.10. Web-based management

Something like proc_open should be used to run it

1.11. Optional libraries


See Install optional libraries in Tiki via Composer

Composer was originally to permit the phpBB project to manage their extensions

1.11.1. Options to implement optional libraries

The should be an option via the command line, and via FTP to add additional optional libraries

1.11.1.1. Option via command line require

How to add a lib
php temp/composer.phar require mpdf/mpdf "*"
php temp/composer.phar update --prefer-dist

Pros
  • Works

Cons
  • Will break on FTP upgrades
  • Can cause merge issues even on svn
  • Requires command line

Notes
  • For this to work, we should store the config in the database, so it can be re-ran at each upgrade
  • Will this work with installs without shell access?

Split composer.json information into two files

Similar to https://github.com/symfony/symfony-standard/blob/master/composer.json and https://github.com/symfony/symfony/blob/master/composer.json, we could split in two files.

tiki-base/composer.json would have most of the information we have today.
tiki/composer.json would call tiki-base/composer.json and permit end users to add their own dependencies, either manually or via the require command. It reduces the odds of merge conflicts

1.11.1.2. Option Mediawiki Composer plugin

Pros
  • Used by others so must work
  • Possible to have multiple composer.json files and have them merged

Cons

An extra lib to maintain

Notes
  • Will this work with installs without shell access?

1.11.1.3. plugins.roundcube.net

Another to investigate: https://plugins.roundcube.net/

1.11.1.4. Composer/Installer/PluginInstaller.php

https://github.com/composer/composer/blob/master/src/Composer/Installer/PluginInstaller.php

1.11.1.5. Locations of optional libraries

  • /vendor/ directory should be deletable so it can be re-created by Composer (and thus libs listed in composer.json ) So for manual downloads, perhaps vendor_custom or vendor_local or something else?
  • See also: File and directory structure revamp
  • Files will be detected by security check on files

1.11.1.6. Other options

Keywords

The following is a list of keywords that should serve as hubs for navigation within the Tiki development and should correspond to documentation keywords.

Each feature in Tiki has a wiki page which regroups all the bugs, requests for enhancements, etc. It is somewhat a form of wiki-based project management. You can also express your interest in a feature by adding it to your profile. You can also try out the Dynamic filter.

Accessibility (WAI & 508)
Accounting 7.x
Administration
Ajax 2.x
Articles & Submissions
Backlinks
Banner
Batch 6.x
BigBlueButton audio/video/chat/screensharing (5.x)
Blog
Bookmark
Browser Compatibility
Calendar
Category
Chat
Comment
Communication Center
Consistency
Contacts Address book
Contact us
Content template
Contribution 2.x
Cookie
Copyright
Credits 6.x
Custom Home (and Group Home Page)
Database MySQL - MyISAM
Database MySQL - InnoDB
Date and Time
Debugger Console
Directory (of hyperlinks)
Documentation link from Tiki to doc.tiki.org (Help System)
Docs 8.x
DogFood
Draw 7.x
Dynamic Content
Preferences
Dynamic Variable
External Authentication
FAQ
Featured links
Feeds (RSS)
File Gallery
Forum
Friendship Network (Community)
Group
Help
History
Hotword
HTML Page
i18n (Multilingual, l10n, Babelfish)
Image Gallery
Import-Export
Install
Integrator
Interoperability
Inter-User Messages
InterTiki
jQuery
Kaltura video management
Karma
Live Support
Logs (system & action)
Lost edit protection
Mail-in
Map
Menu
Meta Tag
Missing features
Visual Mapping 3.x
Mobile Tiki and Voice Tiki
Mods
Modules
MultiTiki
MyTiki
Newsletter
Notepad
OS independence (Non-Linux, Windows/IIS, Mac, BSD)
Organic Groups (Self-managed Teams)
Payment 5.x
Performance Speed / Load / Compression / Cache
Permission
Poll
Profiles
Quiz
Rating
Realname
Report
Revision Approval
Score
Search engine optimization (SEO)
Search
Security
Semantic links 3.x
Share
Shopping Cart 5.x
Shoutbox
Site Identity
Slideshow
Smarty Template
Social Networking
Spam protection (Anti-bot CATPCHA)
Spellcheck
Spreadsheet
Staging and Approval
Stats
Survey
Syntax Highlighter (Codemirror)
Tablesorter
Tags 2.x
Task
Tell a Friend, alert + Social Bookmarking
Terms and Conditions
Theme
TikiTests 2.x
Timesheet
Token Access
Toolbar (Quicktags)
Tours
Trackers
TRIM
User Administration
User Files
User Menu
Watch
WebHelp
Webmail and Groupmail
WebServices 3.x
Wiki 3D
Wiki History, page rename, etc
Wiki plugins extends basic syntax
Wiki syntax text area, parser, etc
Wiki structure (book and table of content)
Workspace and perspectives 4.x
WYSIWTSN 4.x
WYSIWYCA
WYSIWYG 2.x
XMLRPC




Useful Tools