# Console & Commands (Symfony) > คำสั่งที่กำหนดเอง, อาร์กิวเมนต์, ตัวเลือก, การจัดรูปแบบเอาต์พุต, คำสั่งแบบโต้ตอบ, แถบความคืบหน้า - 18 คำถามสัมภาษณ์ - Mid-Level - [คำถามสัมภาษณ์: Symfony](https://sharpskill.dev/th/technologies/symfony/interview-questions.md) ## 1. ควรขยายคลาสฐานใดเพื่อสร้าง console command แบบกำหนดเองใน Symfony? **คำตอบ** ในการสร้าง console command ใน Symfony ต้องขยายคลาส Command จากคอมโพเนนต์ Console คลาสนี้มีเมธอดทั้งหมดที่จำเป็นในการกำหนดชื่อ คำอธิบาย อาร์กิวเมนต์ และตัวเลือกของคำสั่ง รวมถึงเมธอด execute() ที่บรรจุตรรกะทางธุรกิจ แอตทริบิวต์ #[AsCommand] ช่วยให้กำหนดค่าคำสั่งแบบประกาศได้ ## 2. แอตทริบิวต์ PHP ใดที่อนุญาตให้กำหนดค่า command ของ Symfony แบบ declarative ตั้งแต่ PHP 8? **คำตอบ** แอตทริบิวต์ #[AsCommand] ที่ถูกนำมาใช้ใน Symfony 6 ช่วยให้สามารถกำหนดค่า command แบบ declarative ได้ โดยรับชื่อ command เป็นอาร์กิวเมนต์แรกและรับคำอธิบายเป็นทางเลือก สิ่งนี้แทนที่การกำหนดค่าในเมธอด configure() สำหรับข้อมูลพื้นฐาน ทำให้โค้ดอ่านง่ายและกระชับขึ้น ในขณะที่ยังคงสามารถใช้ configure() สำหรับการกำหนดค่าที่ซับซ้อนกว่าได้ ## 3. ความแตกต่างพื้นฐานระหว่าง argument และ option ใน command คอนโซลของ Symfony คืออะไร? **คำตอบ** argument คือค่าตามตำแหน่ง ซึ่งจำเป็นหรือเป็นทางเลือกก็ได้ ถูกส่งต่อทันทีหลังชื่อ command (เช่น app:user:create john) ส่วน option จะนำหน้าด้วย -- (หรือ -) และอาจมีค่าหรือเป็น flag แบบบูลีน (เช่น --verbose, --format=json) arguments มีลำดับและถูกระบุด้วยตำแหน่ง ในขณะที่ options สามารถปรากฏในลำดับใดก็ได้ ## มีอีก 15 คำถาม - เมธอดใดของ command ที่บรรจุตรรกะหลักที่จะถูกเรียกใช้? - จะกำหนด argument ที่จำเป็นใน command ของ Symfony ได้อย่างไร? สมัครฟรี: https://sharpskill.dev/th/login ## หัวข้อสัมภาษณ์ Symfony อื่นๆ - [PHP สมัยใหม่ (8.1+)](https://sharpskill.dev/th/technologies/symfony/interview-questions/php-modern-features.md): 20 คำถาม, Junior - [พื้นฐาน Symfony](https://sharpskill.dev/th/technologies/symfony/interview-questions/symfony-basics.md): 25 คำถาม, Junior - [Routing & Controllers](https://sharpskill.dev/th/technologies/symfony/interview-questions/routing-controllers.md): 20 คำถาม, Junior - [Twig & Templates](https://sharpskill.dev/th/technologies/symfony/interview-questions/twig-templates.md): 20 คำถาม, Junior - [พื้นฐาน Doctrine ORM](https://sharpskill.dev/th/technologies/symfony/interview-questions/doctrine-orm-basics.md): 25 คำถาม, Junior - [ฟอร์ม Symfony](https://sharpskill.dev/th/technologies/symfony/interview-questions/forms.md): 22 คำถาม, Junior - [การตรวจสอบความถูกต้องของข้อมูล](https://sharpskill.dev/th/technologies/symfony/interview-questions/validation.md): 18 คำถาม, Junior - [Dependency Injection & Services](https://sharpskill.dev/th/technologies/symfony/interview-questions/dependency-injection.md): 24 คำถาม, Mid-Level - [Security & Authentication](https://sharpskill.dev/th/technologies/symfony/interview-questions/security-authentication.md): 26 คำถาม, Mid-Level - [Doctrine ขั้นสูง](https://sharpskill.dev/th/technologies/symfony/interview-questions/doctrine-advanced.md): 24 คำถาม, Mid-Level - [API Platform](https://sharpskill.dev/th/technologies/symfony/interview-questions/api-platform.md): 22 คำถาม, Mid-Level - [Serializer Component](https://sharpskill.dev/th/technologies/symfony/interview-questions/serializer.md): 20 คำถาม, Mid-Level - [Events & Event Subscribers](https://sharpskill.dev/th/technologies/symfony/interview-questions/events-subscribers.md): 20 คำถาม, Mid-Level - [Messenger Component](https://sharpskill.dev/th/technologies/symfony/interview-questions/messenger.md): 22 คำถาม, Mid-Level - [HTTP Client](https://sharpskill.dev/th/technologies/symfony/interview-questions/http-client.md): 18 คำถาม, Mid-Level - [Cache & ประสิทธิภาพ](https://sharpskill.dev/th/technologies/symfony/interview-questions/cache.md): 20 คำถาม, Mid-Level - [Workflow Component](https://sharpskill.dev/th/technologies/symfony/interview-questions/workflow.md): 18 คำถาม, Mid-Level - [Testing Symfony](https://sharpskill.dev/th/technologies/symfony/interview-questions/testing.md): 22 คำถาม, Mid-Level - [Mailer Component](https://sharpskill.dev/th/technologies/symfony/interview-questions/mailer.md): 16 คำถาม, Mid-Level - [การแปลและ i18n](https://sharpskill.dev/th/technologies/symfony/interview-questions/translations.md): 16 คำถาม, Mid-Level - [EasyAdmin Bundle](https://sharpskill.dev/th/technologies/symfony/interview-questions/easyadmin.md): 18 คำถาม, Mid-Level - [สถาปัตยกรรม Symfony](https://sharpskill.dev/th/technologies/symfony/interview-questions/architecture-patterns.md): 24 คำถาม, Senior - [ประสิทธิภาพและการเพิ่มประสิทธิภาพ](https://sharpskill.dev/th/technologies/symfony/interview-questions/performance-optimization.md): 22 คำถาม, Senior - [ความปลอดภัยขั้นสูง](https://sharpskill.dev/th/technologies/symfony/interview-questions/security-advanced.md): 22 คำถาม, Senior - [Custom Bundles](https://sharpskill.dev/th/technologies/symfony/interview-questions/custom-bundles.md): 20 คำถาม, Senior - [Microservices ด้วย Symfony](https://sharpskill.dev/th/technologies/symfony/interview-questions/microservices.md): 22 คำถาม, Senior - [Real-time & WebSockets](https://sharpskill.dev/th/technologies/symfony/interview-questions/real-time.md): 18 คำถาม, Senior - [Deployment & DevOps](https://sharpskill.dev/th/technologies/symfony/interview-questions/deployment-devops.md): 20 คำถาม, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/th/technologies/symfony/interview-questions/console-commands