Closed furey closed 7 years ago
Hi @furey sorry for the delay, unfortunately had IRL events to manage. But I was very happy to see this PR! I have tested it out in some old projects and it seems to work just as intended :) Awesome tests by the way! And there was reason for refactoring so thats all good.
You beat me to making a new gif also. Darnit, next time it should feature you and Jon Snow haha! Thanks man!
@furey I just pushed 1.0.0, hope you dont mind we skipping 0.9!
Hey @ajthinking,
A 1.0.0
release is a great idea – nice one!
The next feature I'm looking at implementing is recursive model searching, so if you set a namespaces_and_paths
record with an asterisk at the end (e.g. ''/app/Models/*'), Tinx will recursive search all directories within to sniff out all your models. Sound cool?
Hey while I think of it, can I propose the following tweaks to the repo overview (feel free to ignore if not appropriate)?
For better discoverability, add the topics: laravel
, php
, tinker
So the description is in sync with the README and features the word "Laravel", ensuring it still fits on one line, change it to something like:
Reload your Laravel Tinker session from inside Tinker, plus automatic shortcuts for first(), find(), search, and more!
E.g.
Cheers!
Recursive model searching sounds great! I dont know if its good or bad so just consider it as inspiration: I have seen this syntax in other software:
all/files/in/folder/*
all/files/in/folder/recursive/**/*
Topics and desc: Good idea, added!
Cheers ^ ^
@ajthinking Ending in an asterisk makes perfect sense. Cheers!
Summary
• Added "pascal" naming strategy/tests (replaces "shortestUnique" as default) • Added console "Class/Shortcuts" table (replaces
names()
; filterable e.g.names('user')
) • Added "illuminate/container:~5.2" dependency (supporting back to Laravel 5.2) • Significant architectural refactors • Update README (including GIF)Pascal Naming
I've implemented a fairly bullet proof naming strategy which I've simply called
pascal
as it's based on the first pascal case characters of a model's short class name (but varies from this when naming conflicts occur as it attempts to keep searching for unique variations).I've written tests demonstrating how the strategy works in
/tests/PascalStrategyTest.php
./src/Naming/PascalStrategy.php
is also fully commented for further examination.The
shortestUnique
source has moved to/src/Naming/ShortestUniqueStrategy.php
.Strategy Interface
Both strategies now implement the new
Ajthinking\Tinx\Naming\Strategy
interface.Users can create their own
Strategy
implementation and hook it into Tinx by setting their implementation's full class name as theirstrategy
config value like so:Shortcuts Table
I'm now displaying a table of user "Class/Shortcuts" when Tinx loads:
These shortcuts only appear on load if a user's session satisfies their
names_table_limit
config value (defaults to10
). This value exists so projects with a huge number of models don't get smashed by a massive list of shortcuts on load, unless the user specifically sets thatnames_table_limit
value to-1
(or boots Tinx with averbose
flag, e.g.php artisan tinx -v
).names()
This table also displays when the
names()
function is called during a session (replacing the previous implementation which simply dumped$names
):The
names()
function also accepts string filters as parameters which if passed filters the rows displayed by the shortcuts table:Architectural Refactors
Apologies for all the refactoring! I went down the rabbit implementing "pascal" naming, but the functional benefits should outweigh the refactor costs.
Next Steps
Hi @ajthinking,
When you get time, can you please have a play and let me know how you go.
If approved, I suppose these changes necessitate a full point release?
Cheers!
🤓👍