In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you the method of pr a composer package, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Because in actual development we use the BenSampo/laravel-enum (https://github.com/BenSampo/laravel-enum) package to manage enumerations.
In standardization projects (such as internationalization), this package is actually quite good. But in small projects, adding enumerated classes first and then adding translations to enums.php makes people feel very tedious.
Like this:
So I am very interested in reading the package of "translation" for this note.
But the problem is, this package can only read enumeration translations. What if I need an array?
Like this:
AppStatus::toSelectArray ()
I want to use this bag, but I also want to use toArray, I meet these two conditions, I can do it in a small project without losing elegance.
So, I decided to fork a method to modify and add toArray.
After fork is ready, add a folder of packages in the root directory of the project. In this folder, git clone github.com/liaoshengping/x-phalcon...
Add in composer.json, local directory
"repositories": [{"type": "path", "url": "packages\\ x-phalcon-enum"}]
Next
Composer require limingxinleo/x-phalcon-enum dev-master
The same file as packages will be generated in vendor. Now that you have mapped to packages, you just need to modify the file in it.
Add a static method to toArray in Enum.php.
Public static function toArray () {$ref = new ReflectionClass (static::class); $properties = $ref- > getDefaultProperties (); $_ adapter = new ReflectionAdapter (static::class); $arr = $_ adapter- > getAnnotationsByName ('Message', $properties); return $arr;}
Push to your own master and create a Pull Request, as shown in the figure:
Wait for the boss to check the code, and merge if it is passed.
This completes my first pr.
The above is all the content of this article "pr a composer package method". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.