Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Adding an index and clarifying suggested usage #116

Merged
merged 1 commit into from
Oct 13, 2024

Conversation

borkweb
Copy link

@borkweb borkweb commented Sep 20, 2024

This PR does a couple of things:

  1. Rewords the intro paragraph a bit to be slightly less technical
  2. Adds a table of contents
  3. Adjusts the installation instructions to promote the usage of the .phar approach over the dev dependency approach
  4. Tweaks the Usage section to show a couple ways to execute Strauss
  5. Removes the dump-autoload recommendation in favor of just recommending it always.
  6. Moved breaking changes down lower since it is called out in the ToC

Let me know if you'd like me to break these doc changes out into separate PRs so you can accept or deny them on their own! I definitely made some assumptions based on StellarWP's heavy usage of the tool 🕺

This PR does a couple of things:

1. Rewords the intro paragraph a bit to be slightly less technical
2. Adds a table of contents
3. Adjusts the installation instructions to promote the usage of the .phar approach over the dev dependency approach
4. Tweaks the `Usage` section to show a couple ways to execute Strauss
5. Removes the `dump-autoload` recommendation in favor of just recommending it always.

Let me know if you'd like me to break these doc changes out into separate PRs so you can accept or deny them on their own!

A fork of [Mozart](https://github.com/coenjacobs/mozart/). For [Composer](https://getcomposer.org/) for PHP.
A fork of [Mozart](https://github.com/coenjacobs/mozart/) for [Composer](https://getcomposer.org/) for PHP.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was using the punctuation as emphasis. I think both are valid and neither is better.


The primary use case is WordPress plugins, where different plugins active in a single WordPress install could each include different versions of the same library. The version of the class loaded would be whichever plugin registered the autoloader first, and all subsequent instantiations of the class will use that version, with potentially unpredictable behaviour and missing functionality.
Have you ever activated a WordPress plugin that has a conflict with another because the plugins use two different versions of the same PHP library? **Strauss is the solution to that problem** - it ensures that _your_ plugin's PHP dependencies are isolated and loaded from your plugin rather than loading from whichever plugin's autoloader registers & runs first.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the tone I would go for exactly. But my paragraph wasn't beautiful either.


Require as normal with Composer:
### As a `.phar` file (recommended)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Phive, phar.io, is the ideal way, but it's not how I use it myself so I'm hesitant to write documentation for something I don't do myself.

Also is using bin as the directory for downloaded tools convention? It is for the tools being distributed. Easily manageable with .gitignore as you're recommending.

"bin": ["bin/strauss"],


```json
"scripts": {
"prefix-namespaces": [
"strauss"
"sh -c 'test -f ./bin/strauss.phar || curl -o bin/strauss.phar -L -C - https://github.com/BrianHenryIE/strauss/releases/latest/download/strauss.phar'",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is sh -c needed? I think that should work anyway. Maybe for GitHub Actions?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without sh -c, the initial run when the phar file does not exist downloads and errors out the command. Wrapping in the sh -c allows it to do the download in isolation and then continue on with the composer command without error.

Perhaps there’s a cleaner way, but that is what I use!

or
This provides `composer strauss`, which does the following:

1. The `sh -c` command tests if `bin/strauss.phar` exists, and if not, downloads it from [releases](https://github.com/BrianHenryIE/strauss/releases).
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test -f tests does it exist. sh -c starts a new shell for the quoted commands.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the intent of the sh -c callout was to reference the line itself, not just the sh -c portion. Your point is good, though :)


### As a dev dependency via composer (not recommended)

If you prefer to include Strauss as a dev dependency, you can still do so. You mileage may vary when you include it this way.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit vague. ~"This will not work if your plugin targets a version lower than Strauss's minimum, 7.4, or if Strauss happens to have dependency requirements whose versions constrains are incompatible with other packages you are installing"

@BrianHenryIE BrianHenryIE merged commit b7f4225 into BrianHenryIE:master Oct 13, 2024
@borkweb borkweb deleted the docs/reformatting branch October 15, 2024 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants