thisbythem / stag

The Statamic CLI
36 stars 4 forks source link

Alternate directory structures #8

Closed curtisblackwell closed 6 years ago

curtisblackwell commented 9 years ago

By default, Stag won't work with how I set up my Statamic sites, because my dir structure looks like this:

~/Sites/mysite/
  public_html/
    _add-ons;
    _app/
    …
  dist/
  package.json
  Gruntfile.js
  …

I imagine there are other people who have other structures that Stag doesn't fit with w/o tweaking this path. I think it'd be good to have a documented way of defining BASE_PATH and any future constants that may need to be tweaked.

My quick and dirty solution was to create a config file (~/Sites/mysite/.stag.php) that defines the BASE_PATH constant and uses a require_once in bin/stag.

nobodyiscertain commented 9 years ago

Hi Curtis,

Can you explain a little more on how it doesn't work? Is it just the executable that wasn't found or are the commands botched as well? I'd like to find a way for people to get this working with alternate directory structures without forcing everyone to have an extra file in the setup / install.

curtisblackwell commented 9 years ago

Ah, sorry about the delay. Deleted the notification email on my phone expecting to be reminded by a notification on Github, but I didn't see one.

Anyway, here's the error I'm getting:

PHP Warning:  require_once(./_app/vendor/Slim/Slim.php): failed to open stream: No such file or directory in /Users/curtisblackwell/Sites/my-site/public_html/_add-ons/stag/bin/stag on line 14

Warning: require_once(./_app/vendor/Slim/Slim.php): failed to open stream: No such file or directory in /Users/curtisblackwell/Sites/my-site/public_html/_add-ons/stag/bin/stag on line 14
PHP Fatal error:  require_once(): Failed opening required './_app/vendor/Slim/Slim.php' (include_path='.:/usr/local/Cellar/php55/5.5.21/lib/php') in /Users/curtisblackwell/Sites/my-site/public_html/_add-ons/stag/bin/stag on line 14

Fatal error: require_once(): Failed opening required './_app/vendor/Slim/Slim.php' (include_path='.:/usr/local/Cellar/php55/5.5.21/lib/php') in /Users/curtisblackwell/Sites/my-site/public_html/_add-ons/stag/bin/stag on line 14

My $PATH accounts for the alternate structure with public_html/_add-ons/stag/bin.

I agree, another file isn't desirable, but it was the quickest way I knew how to account for it. I haven't had a chance to revisit it yet.


P.S.
This is a project I'd be interested in contributing to. I started and temporarily released something similar a few years ago, but deleted its public presence due to the drastic changes Statamic was undergoing at the time.

Let me know if there's anything specific you want assistance on. I'm sure I'll have some ideas of my own as I use it more.

nobodyiscertain commented 9 years ago

Ah, ok. I think your approach with the dotfile is good, but I think we should check for existence of the file first and include it, and if not just roll with the default, that should eliminate the need for people to move that file over.

The only other thing I can think would be to set that in the config. The problem is we're so early in the bootstrapping process of Statamic itself, that it'd need to load the YAML parser and other helper files to grab that value, and that could get a little tricky, considering we don't really have a BASE_PATH yet...

Wanna take a stab at that?

And awesome about contributing! I've got a couple of issues currently that I'm working on, and have some ideas for a major overhaul / rewrite. Any time you've got to throw at it, just email me directly and let's figure it out!

curtisblackwell commented 9 years ago

Ah, good call.

I had a huge spike in work recently, which leaves me with less time than usual, so not sure about when I'll be able to help more.

I should have time to tweak this to your suggestion within the next week or so, though.

nobodyiscertain commented 9 years ago

No problemo Curtis, thanks for the follow up.

curtisblackwell commented 9 years ago

Hey, finally got around to it. Let me know if there's anything else.