[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

I created a gacha API using PHP with GitHub Copilot!

nice to meet you

Thank you for opening this article.

My name is Shinta from the System Development Department.

We've been living in an era of tremendous interest in the development of AI technologies such as ChatGPT for some time now.

In order not to be left behind in such a big AI era, this time I tried coding using GitHub Copilot

How to install

GitHub Copilot can be used by installing a plugin in editors such as Visual Studio Code or JetBrains IDE.

You can check how to install plugins for each editor this link

you will need to register using this link before installing the plugin

Note! ! !

If you leave the default settings for the personal plan, your source code will be used to learn Copilot.

You can change it to prevent it from being learned, so be sure to change it. If you are using the Business plan, I think it is set to not be learned by default.

How to use

GitHub Copilot can be used with code completion suggestions.

While you are typing, a code completion candidate will appear in gray text, so you can select it to complete the code.

Similar to regular code completion, code completion suggestions can be displayed using shortcut keys such as Ctrl+Space

Usage example

I use laravel with PHP8.2

I used IntelliJ IDEA Ultimate the IDE

I will try to create an API that runs gacha using only comments as much as possible.

I entered only the comment part, and sometimes the variable name was wrong, so I corrected that part.

When you write a comment, candidates will appear as shown in the red frame, so if there is no problem, press Enter and the comment will be completed.

The lotteryItem function does not exist at this point, so we need to create it.

Create lottery processing lotteryItem

When I entered the function name lotteryItem, a perfect source appeared as a candidate.

If you look closely, it is different from the process you actually want to create.

  • With rand(0,$sumWeight) $sumWeight is 10000, 0 will also be drawn between 0 and 10000.
  • I want to use mt_rand instead of rand
  • Personally, I find addition processing easier to see than subtraction processing, so I would like to change it.
  • Argument is not a Collection
  • The comment is a little strange

I'll try to fix it

Operation confirmation results

I think there's probably no problem!

Thoughts after using it

Complement is not very effective in the early stages

While I was creating the lottery function, it only completed a few lines. I think it's probably because they don't understand what they want to create because they don't have a lot of existing code.

At a certain point, it suddenly complements you strongly.

When I created the lotteryItem function, at a glance I found the perfect source. There were some mistakes, but they were within the scope of being correctable.

I think that the more descriptions there are, the more accurate the completion will be.

If the completion candidates are different from your intention, you can suggest multiple candidates.

It will give you several suggestions, so you can choose the one that suits your intentions.

When the process you want to create becomes clear, you can write comments automatically.

For example, if you write a process to obtain data from a model called Gacha Master, the next line will output a comment that says " Error" if the Gacha Master data does not exist

I'm quite happy because I can simply reduce the number of types.

Future challenges

Learn how to write comments so that Copilot can understand them properly.

If the comment is too vague, the completion candidates may be different from what you intended.

You won't know anything about this unless you actually try it, so I think it's a good idea to try it out and make adjustments as appropriate.

Depending on the process, the wrong code may be completed.

For example, when creating a login process that involves many samples, a fairly accurate completion will come out, but this time's gacha-like process is a little less accurate. (I feel like it)

You will receive source code that looks like that, so be careful if you use it as is, as it may cause bugs.

It is best not to use it for anything other than processes that you can write on your own.

There is a high probability that an inappropriate code will be returned for a long time. I glanced at it and didn't notice it! If you do so, it will cause a big disaster later on.

Especially for people with little programming experience, it can be difficult to judge how much to trust, so be sure to check whether the processing is actually correct!

summary

GitHub Copilot is quite convenient. If you are clear about what you want to create, you can leave a comment and let Copilot write the source, which greatly improves work efficiency.

However, if you rely too much on suggestions, you may not notice bugs, or if you follow them too much, you may not have the ability to think and implement them yourself.

As the name suggests, Copilot is a co-pilot that assists you, so it is important that you write the code as the main pilot.

Have a nice flight!

If you found this article helpful , please give it a like!
11
Loading...
11 votes, average: 1.00 / 111
1,785
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

The person who wrote this article

About the author

Shinta

I'm a game engineer born in Yokohama, and I'm a gutsy engineer!