Hi, folks!
I have the greatest puzzle of this week. How to properly develop an extension?
First of all, my configuration.
Laptop: composer, git, IDE with enabled autoupload (excluded /vendor and /runtime)
Dev-server: nginx, php, composer, git, etc. (in the same subnet, literally near, no potential network problems)
Typical workflow:
-
Write code in IDE (phpstorm)
-
Ctrl+S (autoupload)
-
F5 in browser (figuratively)
-
It works!
-
"git commit, git push" on the laptop
-
"git reset, git pull" on the dev
There are implemented feature and two clean and updated copies of repo with predictable behavior without trash, forgotten changes, etc.
Probably not the best way. If the main problem is here, kick me immediately!
(Nota bene! I’m the only developer, there is no conflicts like “another” developer uploads code in seconds before my surprise “git clear” and his “F5 in browser” makes him cry.)
Anyway. I’m trying to create extension.
How it looks like:
-
Google it twice
-
RTFM
-
Go to gii, fill all fields, press "Generate"
-
Go to runtime/tmp-extensions/yii2-myextension
-
"git init, git commit, git push"
-
Add repo into "repositories" section of composer.json
-
Run "composer require mynickname/yii2-myextension"
-
DEVELOP! (<— a problem)
-
Publish on packagist
-
World-wide fame, girls, cold beer (<— not a problem)
But, emmm…
Do I understand correctly, when I develop I need to:
-
Clone repo to dev (or laptop - depends on the scene of action from previous list)
-
Write code in IDE
-
"git commit, git push" from the laptop
-
Go to dev runtime/tmp-extensions/yii2-myextension
-
git pull
-
composer update
-
F5 in browser
-
It doesn’t work :’( Go to 1.
Too many steps and too many odd commits, isn’t it? Moreover, to many network transmissions.
Okay. Delete “runtime/tmp-extensions/yii2-myextension” from autoupload excluded list. Not cool. Now we don’t need no bad connection. We don’t need no push and pull. But there are commits and “composer update”.
Okay. Add “packages” directory under @app/. Now I don’t delete /runtime from excluded. But (see previous).
Okay. Try to use “path” type of repository instead of “git” type (docs promise that “package/yii2-myextension” directory will be symlinked to “vendor/mynickname/yii2-myextension”. Or I read it wrong?). It seems to be awesome. I don’t need commit any change, autoupload is on.
But last method doesn’t work for me. composer throws “No composer.json
file found in any path repository” when it exists and “composer validate” == ok.
And now the major question: What kind of developing process of extension do you use?
And another one: What am I doing wrong? ("All of it" is probably correct answer.)