Composer screencast // trouble with the content directory

Hey there:

So I just followed along step-by-step with @swalkinshaw in the Composer screencast and set up a new local install. I thought I got everything down, but in the end, the content directory (what Scott names ‘app’ in the video) isn’t working properly. When I load the site, it’s not finding any of the theme css files and when I’m logged into the WP dashboard in wp-admin/themes the screenshots of the themes don’t display.

Here’s what I entered into Terminal (bash) according to Scott’s lead.

$ cp wp/index.php wp/wp-config-sample.php .
$ mv wp-config-sample.php wp-config.php
$ cp -R wp/wp-content .
$ mv wp-content content
$ ls 
total 32
composer.json
composer.lock
content
index.php
vendor
wp
wp-config.php

And I modified the wp-config.php file with the code from Mark Jaquith’s WordPress Skeleton:

define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/content' );
define( 'WP_CONTENT_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/content' );

When I drop the Roots theme into my content/themes directory, it shows up in the wp-admin/themes dashboard. So clearly, something is working.

I’ve gone back and reviewed the screencast a second time and can’t figure out where I might have gone off the rails… Any thoughts on what could be going wrong? Where to look?

Thanks!

Either the file permissions are set incorrectly or it’s a rewrites issue.

If theme is working but assets like CSS, JS, and images aren’t, then it sounds like a rewrites issue. Try disabling them https://github.com/roots/roots/blob/master/lib/config.php#L6

Thanks @Foxaii and @swalkinsha for the replies. Still a bit stuck here.

I disabled rewrites in Roots, but that didn’t have any effect. And actually none of the themes are working. By that I mean that the images are missing and there’s no CSS.

Not sure what to do next. Would welcome any additional advice …

Here are the file permissions:

-rw-r--r--   1 xyz  staff   502  composer.json
-rw-r--r--   1 xyz  staff  2537  composer.lock
drwxr-xr-x   6 xyz  staff   204  content
-rw-r--r--   1 xyz  staff   398  index.php
drwxr-xr-x   6 xyz  staff   204 vendor
drwxr-xr-x  23 xyz  staff   782  wp
-rw-r--r--   1 xyz  staff  3293  wp-config.php 

And for the content directory:

-rw-r--r--  1 xyz  staff   28  index.php
drwxr-xr-x  4 xyz  staff  136 plugins
drwxr-xr-x  9 xyz  staff  306 themes

This is what the .htaccess file reads:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Usually when I’m running into an issue like this, Chrome’s inspector and console are helpful. Find out what the error is, then find a CSS or img file in the inspector, and edit the src to see if you can get it fixed. That should give you a better idea of what the error is and how to fix it

In most cases files should be 644 (rw- r-- r–) and folders should be 755 (rwx r-x r-x). Try loading up the stylesheet or one of the images to see if you get a 403 error.

Thanks @kalenjohnson and @Foxaii. With your help, I was able to get to the bottom of it (I think!).

Problem wasn’t with permissions or rewrites, but instead with where I was pointing my virtual host to. I had it set to the subdirectory where I had WordPress installed (usr/name/sites/localdev.dev/wp/) which meant that none of the stuff in the content directory which was in the root directory (usr/name/sites/localdev.dev) was reachable. (Forgive my rather untechnical description.)

When I went into the Settings > General in the wp-admin, I noticed that both
WordPress Address (URL) and the Site Address (URL) were set to http://localdev.dev

The WordPress Address (URL) should have been http://localdev.dev/wp

That was the clue I needed. I reset the localhost location to the root directory, updated the WordPress (URL) in Settings > General and shazam! That fixed it.

Hope this is helpful to someone in the future. Thanks to everyone who chimed in and helped me with this. As someone with limited experience in the command line, I’m feeling pretty amped to have gotten git and composer working. Hooray!

1 Like

Ah I see, I think that was covered in the screencast but it was probably easy to miss.

Modifying your workflow is always difficult at first, because you have to learn something new or do things different than how you’re used to doing it. But you’re on the right track, all these types of things, Composer, Grunt, Vagrant, etc. are going to help immensely with both speed and quality of your work… once you get settled in :smile: