Noor Alam Profile picture
Aug 14 7 tweets 3 min read
#Laravel: Create custom command to make custom class. The example shows how we create a DataTransferObject (DTO) Class by command

🧵Thread MakeDTOCommand.php
Above code will generate DTO class for us. You need some changes.

You need to change the stub path (location of your stub file) on getStub() Image
You need to change the DTO Class savings directory (location of your DTOclasses) on getDefaultNamespace() Image
Stub File
/stubs/DTO.stub

Notice the {{ class }} syntax in the stub file. When we create a DTO class by "php artisan make:dto UserDTO" command, Laravel GeneratorCommand will replace the {{ class }} syntax with UserDTO in the actual DTO class (UserDTO.php) Image
Of course you can add custom syntax to you stub file like {{ DummyRequestClass }} and {{ DummyRequestVariable }} Image
After adding custom syntax to your stub file you have to tell your command to replace those syntax with certain Words. you can do that by overriding buildClass() Image
UserDTO class (/DTOs/UserDTO.php)

Yellow highlighted words are replaced Image

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Noor Alam

Noor Alam Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @radiate_noor

Aug 16
#VSCode extensions for #PHP / #Laravel developer

1. Auto Rename Tag
2. PHP Intelephense
3. PHP Namespace Resolver
4. PHP Debug
5. PHP CS Fixer for Visual Studio Code (code formatter)
6. PHP Create Class
7. PHP Constructor
8. Path Intellisense

🧵Thread
9. PHP Namespace Resolver
10. Laravel 5 Snippets
11. Laravel Blade Snippets
12. Laravel Blade Spacer
13. Laravel Extra Intellisense
14. Laravel goto view
15. Laravel Snippets
16. Prettier - Code formatter (JS, HTML, GraphQL · Markdown · YAML formatter)
17. JavaScript (ES6) code snippets
18. IntelliSense for CSS class names in HTML
Read 4 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(