Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-10-10 22:54:47

gilibaus
Member
From: Italy
Registered: 2013-08-14
Posts: 92
Website

Plugin install via Composer

I am no php expert. Nevertheless I would like to install rah_backup plugin. Installation is via Composer. Will someone please tell me in layman words how to install this plugin? Thanks.

Offline

#2 2015-10-11 16:31:21

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: Plugin install via Composer

I was going to do a short walk-through for you but then ran into a problem myself. This does not mean you will have the same problem.

In principle, it’s very straightforward. Working on a local machine:

1. First see the getting started with composer instructions on how to install composer on your machine. On the mac it’s done in one terminal command and takes a few seconds, on windows there’s an installer to download. You should only need to do this once. If you have done it before, it may return an instruction notice on how to update it.

2. Make sure your local webserver is running.

3. Then open a terminal window (mac) / command line prompt (windows) and cd to your project directory with your textpattern directory (the one with the index.php and the /textpattern directory), e.g. on a mac that might be:

cd /Users/yourusername/Sites/txp-project-folder

replacing yourusername and txp-project-folder with the relevant infos. In the mac terminal you can type cd<space> and then drag the folder into the terminal window from the finder and it will insert the name. I believe the same thing works on windows. In windows you can also right-click on a folder and open command line from that folder.

4. In the terminal then enter the command that gocom specifies in the plugin help:

composer require rah/rah_backup:*

Composer goes off and looks up rah_backup in its directory, then one-by-one checks your version of txp is recent enough and loads all the relevant plugin files and anything they depend on. It knows which files it needs from the composer.json file in gocom’s github repository, and in the respective other files it loads. When it’s done, rah_backup should then be installed.

–––

In practice, however, I get a database connection error and it doesn’t complete:

[InvalidArgumentException]                                        
  Unable connect to Textpattern database: my-db-name@localhost

And I’m not sure why, except that it’s related to this.

Can anyone shed any light on this?

If it’s any help, I’m using MAMP as a local web server and my $PATH variable does include /Applications/MAMP/Library/bin so that the mysql command does execute correctly. The error message contains the correct database name and the isValidConfig() routine is run beforehand without an error, so config.php has obviously been read correctly and contains the necessary details. The site works fine, so the db-connect details must be correct too but it’s obviously throwing an error when reading the db.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2015-10-11 22:12:08

gilibaus
Member
From: Italy
Registered: 2013-08-14
Posts: 92
Website

Re: Plugin install via Composer

Thank you Jakob, now things are getting more clear. One point catches my attention: at the beginning you specify “working on a local machine”. That means that if I want to replicate the installation on my Txp website online, I have to install Composer on the web server? You know, I am on a shared hosting and I guess that would be difficult to do.

Offline

#4 2015-10-11 22:14:46

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: Plugin install via Composer

It seems my problem is specific to MAMP’s mysql socket versus the systems mysql socket location. After taking a hint from this stack overflow thread, I discovered the system was looking for /var/mysql/mysql.sock while MAMP was using /Applications/MAMP/tmp/mysql/mysql.sock. Creating a symlink in the system directory to MAMP’s sock file solved the problem.

You may not have this problem at all.

Long story short: installing via composer does work as described above and within a few seconds of entering the command, the plugin is then installed and you will have a “Backup” item under your “Admin” tab or dropdown in txp. Create a backup directory, make it writeable and set the path to it in the preferences, and after that you can make backups in the backup tab.


TXP Builders – finely-crafted code, design and txp

Offline

#5 2015-10-11 22:21:12

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: Plugin install via Composer

That means that if I want to replicate the installation on my Txp website online, I have to install Composer on the web server? You know, I am on a shared hosting and I guess that would be difficult to do

I think you only need this for installing the plugin. After installation, the plugin is in the database with any necessary project files in a folder called /vendor in your project directory. I’m pretty certain that you can then simply ftp over the entire project folder (including the vendor folder) as normal, and import your database to your online site and adjust your config.php details accordingly as usual.


TXP Builders – finely-crafted code, design and txp

Offline

#6 2015-10-12 08:22:17

gilibaus
Member
From: Italy
Registered: 2013-08-14
Posts: 92
Website

Re: Plugin install via Composer

Crystal clear.
Thanks.

Offline

#7 2015-11-09 00:29:17

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Plugin install via Composer

I don’t know if this has anything to do with what your after, but the subject made me think of something else Gocom was toying with, Textpattern Installer. I’ve not tried anything in that direction, or used Composer, but it seems he was onto something there with respect to managing many plugin updates, themes, dependencies… whatever.

Offline

#8 2015-11-09 06:17:29

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: Plugin install via Composer

Destry wrote #296491:

the subject made me think of something else Gocom was toying with, Textpattern Installer.

Yes, it’s a required component of installing via composer and is automatically used when installing via composer (example). When installing a plugin, it’s included “behind the scenes” so as a normal user you aren’t aware of it (and don’t need to install it separately). Plugin developers can use it to automate installation of their plugins, relevant files and related operations.

One difference when installing using composer is that you don’t see the plugin code in the plug-in panel, just a file include. The plugin code is stored in a file in the vendors subdirectory. Apparently the advantage of using composer over using the plugin tmp directory to install via a file is that the latter method doesn’t reliably trigger install / enable / disable events.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB