Comments (11)
Just ran into something similar as well,
If you use composer's files autoload, it's broken when using Strauss with namespaced functions, e.g.
{
"autoload": {
"files": [
"functions.php"
]
},
}
from strauss.
@defunctl we got around it temporarily by not using declared use function ...
but rather prefixing each call with the FQN
from strauss.
I think this is a duplicate / related of #65 ... both are about namespaced functions.
I have some failing tests written from a when I tried to fix it, but haven't revisited yet:
https://github.com/brianhenryie/strauss/compare/master...BrianHenryIE:strauss:issue-65?expand=1
from strauss.
@danieliser That should be fixed in master now: aab2bf6
@defunctl I'm not sure what your issue really is. The autoloader type should be unrelated to this issue. Can you check does master fix your problem and if not, open a detailed issue?
from strauss.
@BrianHenryIE - Awesome, will give it a try later today. Thanks for fixing that for us.
from strauss.
@BrianHenryIE not sure if it's the same issue, but master still isn't working for me.
Here's a repo detailing the problem, happy to add a new issue if it's not related: https://github.com/defunctl/strauss-test
from strauss.
@defunctl Run composer dump-autoload
after running Strauss for Composer to reindex the files it loads. After you ran it with "delete_vendor_packages": true
it was still looking for /vendor/composer/../ralouphie/getallheaders/src/getallheaders.php
.
from strauss.
@defunctl Run
composer dump-autoload
after running Strauss for Composer to reindex the files it loads. After you ran it with"delete_vendor_packages": true
it was still looking for/vendor/composer/../ralouphie/getallheaders/src/getallheaders.php
.
Nice, that worked!
Shouldn't Strauss just do that after it deletes the vendor packages?
Edit: or perhaps just update the docs to include that step?
e.g.
"scripts": {
"strauss": [
"vendor/bin/strauss",
"@composer dump-autoload"
],
from strauss.
I'll certainly update the documentation. Strauss should do it, maybe, I'm not sure are there cases where you would not want it. I guess I could make it conditional on the delete_vendor_packages
being true
and if someone reports it as problematic, I could revert it. I don't use Composer's own autoloader in plugins so haven't thought about this much. I would like to add some command line output as Strauss runs, maybe it could be documented there too.
from strauss.
@BrianHenryIE let me know if I can help in any way. I could take a stab at improving the documentation, if you're able to tell me a little more about how you personally use it, and if it should be the preferred way to configure Strauss.
Perhaps were all just not using it the most optimal way?
Thanks for all your hard work, it's appreciated.
from strauss.
@defunctl TBH, I'm not using it the way I think it should be used! Instead, I'm using it the way I've always been using it.
There are a few open issues related to this, but I think ideally people would download the strauss.phar
and after running composer install --no-dev
, use it to prefix the contents of /vendor/
without moving/copying anything.
There's at least one related bug right now, where running strauss.phar
twice results in double-prefixed namespaces. I haven't looked into fixing it at all yet.
Whenever I do that, I'd like to look at prefixing the uses of prefixed libraries inside existing code. I.e. make adopting Strauss easy for any codebase. Typically, I'm working on new plugins, so I haven't tried this yet. It should be trivial.
I've added a sentence to the README about composer dump-autoload
, thanks. 18a7884
from strauss.
Related Issues (20)
- Incorrect binary name when installed using composer HOT 2
- Good idea to set `target_directory`to 'vendor'? HOT 1
- Feature: Change WordPress translation domain HOT 1
- Still works? HOT 3
- Add warning about using composer packages installed with symlink HOT 3
- Issue bundling AWS S3 package HOT 3
- Troubles Namespacing WPGraphQL HOT 5
- `exclude_from_copy` does not apply to `files` autoloaders
- delete_vendor_packages deletes needed composer files HOT 2
- Troubles namespacing nesbot/carbon HOT 2
- Infinite loop HOT 2
- Request: prefix global functions. HOT 1
- Strauss Fail when a namespace is mapped to an array of paths HOT 6
- Files autoloader for symlinked package not copied or referenced correctly
- JsonException core PHP class, polyfilled by Symfony, incorrectly replaced
- v0.14.1 no longer parses `<?php namespace ...` HOT 1
- How to handle prefixed dependencies also used by dev-dependencies HOT 9
- Recommended way to handle non-php assets / paths? HOT 2
- Not Namespacing instanceof Statements HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from strauss.