28: Installing Anchor CMS
Readable in 08 minutes, with 0 comments.
So this was a fucking nightmare. I initially downloaded what I thought to be the distributuion version from github, and spent way too much time trying to get whatever composer is to install and download the vendor packages so I could go through the CMS install. It turns out that I wasted my time. Composer won't allow me to download from https through Tor. I can't figure out why, and apparently a bug was fixed to resolve this, but I always have the issues that never get resoled, so I don't know. Then, after looking for a download with the vendor packages bundled in, I noticed the original bundle I downloaded was a duplicate of the source bundle. A mistake in the uploading perhaps?
Anyway, with the vendor files added, the AnchorCMS installer loaded. And oh boy, they only support MySQL, even though their own information mentions SQLite, and they even include the driver information in the code. The only reason I wanted to try this CMS was due to having SQLite support. So I was fully pissed off, having wasted hours trying to install something just to see if I want to switch to it. It isn't worth that hassle.
After a break, I have now bypassed the installer with my own app.php and db.php files. What other information is suposed to go in to those files though, I have no idea. I have also created by own SQLite schema file, and used it to build a database. That step took me to missing data in the meta table. I had hoped to get away without adding any default information, but oh well. After merging the data from the migrations files, I tried again and received a syntax error, which turned out to be a database query that will not work with SQLite. In my quest to find the appropriate method to replace this with, I found a pull request on github:/anchorcms/anchor-cms/pull/1006/files. Cool. Not cool that it hasn't been merged, but whatever. I figured I would hit various other errors after updating the query, so I merged a few pieces, skipping the migrations and installer stuff, since I bypassed that earlier.
I was then informed that I was ''. Digging further, this was simply not having a page set up. Since I had skipped the default database data, I created my own, and refreshed. Ohmygodadoubleslash! After a brief panic, I realised the theme variable was returning blank. I thought I had added reference to the theme at the beginning of all of this, as if I knew I would need it in the future. So the default theme directory name is not being added to the path. Adding another entry in to the database solved this, and I was able to load the main page. However, I could not navigate anywhere else, all links pointed back to the index.
I started to poke around in several files, and eventually saw the admin path. This avoids using ?routes=, which is set in app.php, so I gave the link a go, and saw the log in page. I tested a few other links, but nothing changed, so I removed the setting from app.php and changed the rewrite rules in the .htaccess file to remove index.php. I was getting somewhere. I still needed to make a user to log in to.
After testing everything in the admin panel, I noticed I could not post new entries or pages, though I could edit the defaults I added earlier. So back to digging. I managed to find an exception error hidden behind the inner workings while viewing the browser console. A new 'updated' column wasn't being added to on submission of data, and I had set this to NOT NULL. After looking in to it, I needed to find an SQLite way of filling this in on creation, and correctly update the timestamp after editing a page or post. Cue triggers. Three attempts later, and the database seems stable, the schema is correct and no errors are thrown.
I am so fucking happy right now! All of the hard work over three days eventually paid off (a two minute install my arse). The software looks and feels good. And really, it is the lack of SQLite support that failed here. It's apparently coming in version 1.0, but that was stated four years ago; the current version is 0.12.6.
Do It Yourself:
Since I am a nice person, I have included an SQLite schema file for anyone wishing to avoid going through what I did. The link is handled by fancyBox, so you can open it in a new tab, or 'save link as'. If you try the AnchorCMS installer, the database, app.php and db.php files should be created for you. However, if you wish to skip everything, you will need to create the database manually, and copy two files from the install directory:
/install/storage/application.distro.php > /anchor/config/app.php and
/install/storage/database.distro.php > /anchor/config/db.php, then make the following edits:
In app.php, add:
'driver' => 'sqlite'
Set 'default' to 'sqlite', then add:
, 'sqlite' => [ 'driver' => 'sqlite', 'username' => '', 'password' => '', 'database' => '/path/to/file.db' ] ]
The default username is admin, and the password is sqlite. If you reference the changes within the closed pull request linked above, and the information in this post, everything should work. I built my install from 0.12.6 master @74b3de8. Things may be different in the future. I am not to be held responsible for your machine melting.
Comment on this post.