diff --git a/scripts/roadmap-tree-content.js b/scripts/roadmap-tree-content.js index 992d0161c..c4dfb6330 100644 --- a/scripts/roadmap-tree-content.js +++ b/scripts/roadmap-tree-content.js @@ -13,562 +13,494 @@ const __dirname = dirname(__filename); * @property {string} text - The text content of the node */ -const roadmapId = 'engineering-manager'; +const roadmapId = 'php'; /** @type {Node[]} */ const nodes = [ { - id: 'oKbeLp4YB8rI1Q3vi0EnG', - text: 'Engineering Manager > What is Engineering Management? > EM vs Tech Lead vs IC', + "id": "_hYN0gEi9BL24nptEtXWU", + "text": "PHP > Introduction to PHP" }, { - id: 'aSZ2uVCmpAdEPjJt6VKG4', - text: 'Engineering Manager > What is Engineering Management? > People', + "id": "_LhLDVZjLt1DoAP1NuUES", + "text": "PHP > Introduction to PHP > What is PHP?" }, { - id: 'p9ecMvHCqjmvxf67di7pY', - text: 'Engineering Manager > What is Engineering Management? > Product', + "id": "b2CuLrhsUNnb4OxI6RRAS", + "text": "PHP > Introduction to PHP > Evolution and History" }, { - id: 'iZFn0FaRdrGv_-_8zii_-', - text: 'Engineering Manager > What is Engineering Management? > Process', + "id": "6sHRQTcoKL3TlgNJlwyx8", + "text": "PHP > Introduction to PHP > PHP Versions and Features" }, { - id: 'fBENrXdMhoGYgL_d96tgo', - text: 'Engineering Manager > Software Engineering Background', + "id": "3_TuxOSzBuktBlBF05r_z", + "text": "PHP > Installing PHP" }, { - id: 'iX4HPgoiEbc_gze1A01n4', - text: 'Engineering Manager > > System Design and Architecture', + "id": "36Y1HkHxhuxh2qVQB8NVE", + "text": "PHP > WAMP" }, { - id: 'EY6Hk5wPd9Y_VA1UROk44', - text: 'Engineering Manager > Technical Debt and Management', + "id": "-wniKEBwbF0Fi1fHpF-Gc", + "text": "PHP > XAMPP" }, { - id: '40yK6XzI8lSxdiAXxtF75', - text: 'Engineering Manager > Code Review Best Practices', + "id": "t7p7TU2khaxsZPYAdwFAA", + "text": "PHP > MAMP" }, { - id: '_2xnTKt5yi__jj_WgcLa7', - text: 'Engineering Manager > Technical Documentation', + "id": "7LjxtrmgJtTJc0_kP83Tr", + "text": "PHP > LAMP" }, { - id: 'ikCJ8Ybu2AD1w5VuPNVAO', - text: 'Engineering Manager > Technical Strategy > Technical Roadmapping', + "id": "hzBUHSuFwLYNooF_vEmrs", + "text": "PHP > Basic PHP Syntax" }, { - id: 'FtWNnOE3zObmjS-Og26M3', - text: 'Engineering Manager > Technical Strategy > Architectural Decision-Making', + "id": "D0BtyxyjIBcpfn5wP23WC", + "text": "PHP > Variables and Scope" }, { - id: 'H0aav5qKDNiNegJOGP2rx', - text: 'Engineering Manager > Technical Strategy > Build vs Buy Evaluation', + "id": "srIHPZabaCGdB5VvUXaMa", + "text": "PHP > Data Types" }, { - id: 'd7zMBhMFgY9MwmKC9CVVh', - text: 'Engineering Manager > Technical Strategy > Technical Risk Assessment', + "id": "pzReF4C0mcCWAnpfIJbwl", + "text": "PHP > Casting Data Types" }, { - id: 'EyoVFmqOJbH1sAPHLISFt', - text: 'Engineering Manager > Technical Strategy > Scaling Infrastructure', + "id": "2ykzBBdYhWuM-neGf0AWP", + "text": "PHP > echo" }, { - id: 'QUxpEK8smXRBs2gMdDInB', - text: 'Engineering Manager > Technical Strategy > Legacy System Retirement', + "id": "NQUmO90sqe7fnzod3Ia8H", + "text": "PHP > print" }, { - id: 'pduPcv2QPpVmVvDdK4CPi', - text: 'Engineering Manager > Quality and Process > System Monitoring & Performance', + "id": "wsC7OGXOyfCY4pLLNrR2v", + "text": "PHP > print_r" }, { - id: 'gAEmpSMvNyjmTa5q9oZSg', - text: 'Engineering Manager > Quality and Process > CI/CD Implementation', + "id": "JCCeVC0hOrvIeyfg1ScKA", + "text": "PHP > var_dump" }, { - id: 'bpJPDbifPwS4ScOoATlEI', - text: 'Engineering Manager > Quality and Process > Development / Release Workflow', + "id": "VLRLymQmLfscrBfzXKvHi", + "text": "PHP > Constants" }, { - id: 'q5SJyM1d8cQzzAcR-kotB', - text: 'Engineering Manager > Quality and Process > Testing Strategies', + "id": "IhKjvT6CjRz4dsSU7SNQo", + "text": "PHP > Arrays" }, { - id: 'C2YsaZ32An_UXV8lB7opm', - text: 'Engineering Manager > Quality and Process > Technical Standards Setting', + "id": "j2S8dP3HlAOOoZdpj-7Dx", + "text": "PHP > Arrays > Indexed Arrays" }, { - id: 'sQCLhk__jvbityuuLlxiW', - text: 'Engineering Manager > Quality and Process > Security Best Practices', + "id": "i_NRsOJNNp7AOqMgu5Jg8", + "text": "PHP > Arrays > Associative Arrays" }, { - id: 'o1xPrfg8iNWQpD12xsbQJ', - text: 'Engineering Manager > Quality and Process > Incident Management', + "id": "uARTOZ-ZwugSmbCJoRS5Y", + "text": "PHP > Arrays > Multi-dimensional Arrays" }, { - id: '3na5mBIPl5f6mjEzkgD_C', - text: 'Engineering Manager > People Management > Hiring and Recruitment', + "id": "38YksjvhXCbgnHqkl57Cz", + "text": "PHP > Conditionals" }, { - id: 'tPDmXXjvFI_8-MTo_dEUw', - text: 'Engineering Manager > People Management > Team Structure and Design', + "id": "-McOv-ZPTGayX7Mx2Thw1", + "text": "PHP > Conditionals > if/else" }, { - id: 'eJzYnoB6sArLjXRm51cM4', - text: 'Engineering Manager > People Management > Performance Evaluations', + "id": "bgJ9-m6Fiu3VCc-NZlbpn", + "text": "PHP > Conditionals > switch" }, { - id: 'fhFSR_N4ZDTHINEinubHG', - text: 'Engineering Manager > People Management > Career Development Planning', + "id": "3gNzX-bw2iqur7U7-_W38", + "text": "PHP > Conditionals > match" }, { - id: '0ULnfq0ZFJXgoLbKM1gxC', - text: 'Engineering Manager > People Management > Mentoring and Coaching', + "id": "w0ntgFBhgGd5RUFd-qlPK", + "text": "PHP > Conditionals > Null Coalescing Operator" }, { - id: 'bx2SMhR58ud45se5dK7qS', - text: 'Engineering Manager > People Management > Delegation', + "id": "1NXSk8VZDr89jQTTkOL7x", + "text": "PHP > Conditionals > Null Safe Operator" }, { - id: 'QA5CR5f0geC_RQc_SOK-N', - text: 'Engineering Manager > Leadership Skills > Conflict Resolution', + "id": "qwt8xN4vuTrY-D0czYITI", + "text": "PHP > Loops" }, { - id: 'Az9GgkLFoat2t_sYRUBv5', - text: 'Engineering Manager > Leadership Skills > Feedback Delivery', + "id": "WiGv7vi7Mtw-YqPMcnnyw", + "text": "PHP > Functions" }, { - id: 'U_oOnDXkCE387r9olvMZB', - text: 'Engineering Manager > Leadership Skills > Team Motivation', + "id": "1nODJchgSuWbcvSlxnWeE", + "text": "PHP > Functions > Function Declaration" }, { - id: '7PBmYoSmIgZT21a2Ip3_S', - text: 'Engineering Manager > Leadership Skills > Trust / Influence Building', + "id": "mpQKoBzsOa-5iWo08sOhQ", + "text": "PHP > Functions > Parameters / Return Values" }, { - id: 'h7gEQNbGiabDA1q1Bk_IB', - text: 'Engineering Manager > Leadership Skills > Emotional Intelligence', + "id": "RgVP99rJJ8FVecIA45w20", + "text": "PHP > Functions > Default / Optional Params" }, { - id: 'b3qoH_LuW-Gz4N8WdGnZs', - text: 'Engineering Manager > Communication > One-on-One Meetings', + "id": "RkNjYva8o_jXp9suz5YdG", + "text": "PHP > Functions > Named Arguments" }, { - id: 'C2EQ8JMyK6b4PvgK5TpXb', - text: 'Engineering Manager > Communication', + "id": "Nr5m6wQLp7VyG3AucrSc8", + "text": "PHP > Functions > Anonymous Functions" }, { - id: 'e0ZuiCoS8sJ0XB1lNiz7_', - text: 'Engineering Manager > Team Meetings', + "id": "x7hA2KAzJIjc-prgCEw6V", + "text": "PHP > Functions > Callback Functions" }, { - id: 'gqKEgKjEu5sOf5Gl-HS-j', - text: 'Engineering Manager > Communication > Status Reporting', + "id": "mP1BIkqbWVVTU-zZv1ZL6", + "text": "PHP > Functions > Arrow Functions" }, { - id: 'TVqVlJqegLZRSkwNoHbBf', - text: 'Engineering Manager > Communication > Stakeholder Management', + "id": "D9ybK5INH5zSOcYMb5ZPi", + "text": "PHP > Functions > Recursion" }, { - id: 'ZuZuzwy-Frsn_PFJZVuAQ', - text: 'Engineering Manager > Communication > Cross-functional Collaboration', + "id": "rtmytETfyyLdcXUC0QyzL", + "text": "PHP > Functions > Variadic Functions" }, { - id: 'jt-LF5QbGVs0cwTuHFQF6', - text: 'Engineering Manager > Project Management', + "id": "Kaaqu-mN7xvHN6CbIn616", + "text": "PHP > File Handling > require" }, { - id: '4v5yLKYVcMh0s7SQuf__C', - text: 'Engineering Manager > Project Management > Resource Allocation', + "id": "-CyJbsg2ho3RvfzKnJj5C", + "text": "PHP > File Handling > require_once" }, { - id: '7BcToTqL78QmG4qb43X5Q', - text: 'Engineering Manager > Project Management > Sprint Planning', + "id": "hKfv7V6bl2LXssq9Ffi7C", + "text": "PHP > File Handling > include" }, { - id: '-Qc6E3gkUUonfzifYqeJJ', - text: 'Engineering Manager > Project Management > Release Management', + "id": "SwtLDgyPmDry20qS4FBfH", + "text": "PHP > File Handling > include_once" }, { - id: 'mgw6M8I9qy1EoJpJV-gy1', - text: 'Engineering Manager > Project Management > Risk Management', + "id": "S9wTlkbv9-R6dohhZ47hs", + "text": "PHP > File Operations > Reading Files" }, { - id: 'hH-UDVFlgKoMJcI1ssDFv', - text: 'Engineering Manager > Project Management > Dependency management', + "id": "two4UycJaCfSp6jQqtTAb", + "text": "PHP > File Operations > Writing Files" }, { - id: 'n9gvPHn4c1U-l6v-W9v6r', - text: 'Engineering Manager > Project Management > Agile methodologies', + "id": "tgIyG6vHWpe9sz6lHmj5a", + "text": "PHP > File Operations > File Permissions" }, { - id: 'SuT6q5lMMSyVkadlQp7iU', - text: 'Engineering Manager > Project Management > Project Tracking', + "id": "MRDjEjbkMpk7shcWAoPOF", + "text": "PHP > File Operations > CSV Processing" }, { - id: 'PXobPGPgCX3_55w4UtxT9', - text: 'Engineering Manager > Project Management > Milestone Management', + "id": "DB2cxZE58WCCavW2PNwmf", + "text": "PHP > File Operations > JSON Processing" }, { - id: 'C-lJJSjT8Cxw_UT3ocFsO', - text: 'Engineering Manager > Project Management > Scope Management', + "id": "ggkWo0DRSSDDkHpbiyUyf", + "text": "PHP > File Operations > XML Processing" }, { - id: 'QWO5QFS7kXwfu3aa8IiRt', - text: 'Engineering Manager > Project Management > Timeline Estimation', + "id": "tn_iIfaJZVtPK6vFds7FH", + "text": "PHP > HTTP / Request Handling > HTTP Methods" }, { - id: 'Wd8FCEaGZBTvsD-k4t0r4', - text: 'Engineering Manager > Project Management > KPI Definition', + "id": "GFYGFVfxkOoPI5mI4zSt1", + "text": "PHP > HTTP / Request Handling > $_GET" }, { - id: 'idd92ZTBVUzptBl5jRdc3', - text: 'Engineering Manager > Project Management > Measurement > Velocity Tracking', + "id": "qNG-a4iIO-puZsMwAMzYC", + "text": "PHP > HTTP / Request Handling > $_POST" }, { - id: 'ZWWsuFm_G4kvvl_cv8l_t', - text: 'Engineering Manager > Project Management > Measurement > Quality Metrics', + "id": "A6rfW4uJhyfAX2b18_EEC", + "text": "PHP > HTTP / Request Handling > $_REQUEST" }, { - id: 'ZWWsuFm_G4kvvl_cv8l_t', - text: 'Engineering Manager > Project Management > Measurement > Quality Metrics', + "id": "7Ja2at_N9tRTlvSGahrqn", + "text": "PHP > HTTP / Request Handling > $_SERVER" }, { - id: 'KPDHk7tl_BnIj_obnq3Kl', - text: 'Engineering Manager > Project Management > Measurement > Team Health Metrics', + "id": "sYI7f1PYP7G30_Uj2mZRv", + "text": "PHP > Form Processing" }, { - id: 'g9WWa50V8ZbhIJgBRx0Nd', - text: 'Engineering Manager > Project Management > Measurement > Project Postmortems', + "id": "HNo8QO4aPbvgePiA4l6tq", + "text": "PHP > File Uploads" }, { - id: 'nC5dfGlxbLoXUAp2u-6Gl', - text: 'Engineering Manager > Strategic Thinking > Product strategy alignment', + "id": "CGehmZjcgTWC7fQAvxmNW", + "text": "PHP > State Management" }, { - id: 'vhOHvfF_lfQrrOK6sGLTY', - text: 'Engineering Manager > Strategic Thinking > Business Case Development', + "id": "so03-fK7E2WvTm6XsPq4i", + "text": "PHP > State Management > Cookies" }, { - id: 'XinUWPahOdufmLYcEwMj_', - text: 'Engineering Manager > Strategic Thinking > ROI analysis', + "id": "qobzzgzArNHLLn9Oiqc6G", + "text": "PHP > State Management > Sessions" }, { - id: 'P2gIOt-i0sQEOMBo-XjZO', - text: 'Engineering Manager > > Market awareness', + "id": "93oEIZttb85S23C1fLraP", + "text": "PHP > Basics of Security > Input Validation" }, { - id: '76GjwwEYaEX_kh02OSpdr', - text: 'Engineering Manager > Strategic Thinking > Competitive Analysis', + "id": "801vB_JMas4ucriUmfrLg", + "text": "PHP > Basics of Security > SQL Injection" }, { - id: 'TQY4hjo56rDdlbzjs_-nl', - text: 'Engineering Manager > Strategic Thinking > Competitive Analysis', + "id": "DxqQrToZSayWplKdCkTgT", + "text": "PHP > Basics of Security > XSS Prevention" }, { - id: 'KA0y6KdVTjJFeX3frHUNo', - text: 'Engineering Manager > Organizational Awareness > Company Culture', + "id": "J9yIXZTtwbFzH2u4dI1ep", + "text": "PHP > Basics of Security > CSRF Protection" }, { - id: 'tt02qGHSn4fPbpboZ1Ni_', - text: 'Engineering Manager > Organizational Awareness > Change management', + "id": "JbWFfJiCRrXDhnuIx_lqx", + "text": "PHP > Basics of Security > Password Hashing" }, { - id: 'mjMRNhPkeb4lEZXBb8Iot', - text: 'Engineering Manager > Organizational Awareness > Organization structure', + "id": "HJJzKYXdK4BWITLP4APLZ", + "text": "PHP > Basics of Security > Auth Mechanisms" }, { - id: 'Zoz01JcNU69gr95IcWhYM', - text: 'Engineering Manager > Organizational Awareness > Politics navigation', + "id": "tfC1tCrbvH5J43WUpG9Yb", + "text": "PHP > Basics of Security > Sanitization Techniques" }, { - id: 'Hb_rZe4k37Rr0enSh7woV', - text: 'Engineering Manager > Organizational Awareness > Cross-department collaboration', + "id": "cJtPz1RMN1qDE4eRdv4N_", + "text": "PHP > Database Connectivity > PDO" }, { - id: 'oqjr26B27SHSYVQ4IFnA1', - text: 'Engineering Manager > Financial Management > Budget Planning', + "id": "YLuo0oZJzTCoiZoOSG57z", + "text": "PHP > Database Connectivity > MySQLi" }, { - id: 'iwwxnSVvCmZ57stXwzk8G', - text: 'Engineering Manager > Financial Management > Resource forecasting', + "id": "SeqGIfcLuveZ2z5ZSXcOd", + "text": "PHP > Advanced Database Techniques > Object-Relational Mapping (ORM)" }, { - id: 'rbhZJZtRV1ZZ5QaYW77ry', - text: 'Engineering Manager > Financial Management > Cost Optimization', + "id": "FY-F6n9j29hQrnFry3VGb", + "text": "PHP > Advanced Database Techniques > Database Transactions" }, { - id: 'Imgt669vbUT_Iec2o4Gvt', - text: 'Engineering Manager > Financial Management > Vendor Management', + "id": "txUyPR_tdC8iTJV3RtvBz", + "text": "PHP > Advanced Database Techniques > Connection Pooling" }, { - id: 'ZuZuzwy-Frsn_PFJZVuAQ', - text: 'Engineering Manager > Team Culture > Defining and Enforcing Values', + "id": "M1nVsh_sCSFJRf6-7Ttsj", + "text": "PHP > Advanced Database Techniques > Performance Optimization" }, { - id: '6iM0n4faMNhk4mezS9AcG', - text: 'Engineering Manager > Team Culture > Inclusive environment creation', + "id": "meplwvmHMtI3Sb_fyodzZ", + "text": "PHP > Advanced Database Techniques > Database Migrations" }, { - id: '8Nro6PTkEkNugYBjQfJ6O', - text: 'Engineering Manager > Team Culture > Team Traditions and Rituals', + "id": "yTviiPFR5b_dr3WyxdxxQ", + "text": "PHP > OOP Fundamentals" }, { - id: 'Vb3A4a-UpGTAEs-dVI66s', - text: 'Engineering Manager > Team Culture > Recognition programs', + "id": "PIuplWreo7PFG3Mdn2t6W", + "text": "PHP > OOP Fundamentals > Classes and Objects" }, { - id: 'LE3ykySYFL23KvuwxeBaR', - text: 'Engineering Manager > Team Culture > Social connections', + "id": "oNUt1oT8pYBVvH0S2P6cb", + "text": "PHP > OOP Fundamentals > Constructor / Destructor" }, { - id: 'g9FvFKC715tZL2ZGlPl3N', - text: 'Engineering Manager > Team Culture > Bias Recognition / Mitigation', + "id": "MRAPXshy9RoYdReY6grf_", + "text": "PHP > OOP Fundamentals > Properties and Methods" }, { - id: 'njqjYPMQK3nGYtqHzUylo', - text: 'Engineering Manager > Engineering Culture > Innovation fostering', + "id": "RD2RaBmA2XWkEa13PTCTX", + "text": "PHP > OOP Fundamentals > Access Specifiers" }, { - id: 'aeD-kBZEr1NHFtAD8yHI_', - text: 'Engineering Manager > Engineering Culture > Learning culture development', + "id": "qlkpwXfOc1p7j37hrzffI", + "text": "PHP > OOP Fundamentals > Static Methods and Properties" }, { - id: '74-7hDXaBVXYo6LJdgac_', - text: 'Engineering Manager > Engineering Culture > Knowledge sharing practices', + "id": "c5q2e_jyMt8Pir5Od3lRi", + "text": "PHP > OOP Fundamentals > Inheritance" }, { - id: 'Cq0OFaWqSRathZO-bxBrP', - text: 'Engineering Manager > Engineering Culture > Technical excellence mindset', + "id": "gtq5KrghF28f5G8nuDcYQ", + "text": "PHP > Polymorphism" }, { - id: 'fYkKo8D35AHd8agr3YrIP', - text: 'Engineering Manager > > Blameless Post-mortems', + "id": "ub79EkMiOmPBwXLRuYFL8", + "text": "PHP > Abstract classes" }, { - id: 'Xaeb67Nqdi0kwvehQUYeJ', - text: 'Engineering Manager > Incident Response > Emergency protocols', + "id": "vu0H-TsD7hkJgOQbSRj92", + "text": "PHP > Interfaces" }, { - id: 'LQ3YfAgJ4UaDgtnN-cMht', - text: 'Engineering Manager > Incident Response > War Room Management', + "id": "GR09ns9B-0cONQaQ_uj-7", + "text": "PHP > Traits" }, { - id: 'irEwTIubCjORnlH27QpEo', - text: 'Engineering Manager > Incident Response > Stakeholder Communication', + "id": "9raJ06lKRZITbjWeLil-F", + "text": "PHP > Namespaces" }, { - id: '2fHcb1dAnf34APCAAlwnR', - text: 'Engineering Manager > Incident Response > Service Recovery', + "id": "rSXsPWto7Jeyw3Szl9pvf", + "text": "PHP > Magic methods" }, { - id: '8zyK34SwHry2lrWchw0KZ', - text: 'Engineering Manager > Incident Response > Post-incident analysis', + "id": "sPW-Ti2VyNYzxq6EYkbn7", + "text": "PHP > Type Declarations" }, { - id: '2RwpGPegD2GyiiV6SVbbM', - text: 'Engineering Manager > Risk Mitigation > Contingency planning', + "id": "KEE50C6lOS4eX8sAbfhYe", + "text": "PHP > Dependency injection" }, { - id: 'KOTzJ8e7mc0wmF46vrj3I', - text: 'Engineering Manager > Risk Mitigation > Disaster recovery', + "id": "zsscRQZIq5o0JZir9hlz-", + "text": "PHP > Laravel" }, { - id: 'v6N7BH0B55gX0oNXb55D7', - text: 'Engineering Manager > Risk Mitigation > Business continuity', + "id": "57VSMVePOr9qUD5x_LNdf", + "text": "PHP > Symfony" }, { - id: 'FNp4-RgPvfC76pJKjX56a', - text: 'Engineering Manager > Risk Mitigation > Security incident handling', + "id": "yVFDu2aTiEZ4PWMdKdW2P", + "text": "PHP > Composer" }, { - id: 'kQG_wk66-51dA4Ly9ivjM', - text: 'Engineering Manager > Risk Mitigation > Production issues management', + "id": "xZf2jjnCVHwYfDH2hs9kR", + "text": "PHP > Packagist" }, { - id: 'mIUx8zAHWyPWPGvxuTK4y', - text: 'Engineering Manager > Team Support > Contingency planning', + "id": "qFiTsf6Es-gwqe6J6bdL1", + "text": "PHP > Autoloading" }, { - id: 'nnoVA8W70hrNDxN3XQCVL', - text: 'Engineering Manager > Team Support > Disaster recovery', + "id": "NfBKKwG2GGBPppOjoLLBg", + "text": "PHP > PHPUnit" }, { - id: 'FwK-B7jRbBXVnuY9JxI1w', - text: 'Engineering Manager > Team Support > Business continuity', + "id": "d6MydchA52HIxfAUjmZui", + "text": "PHP > Pest" }, { - id: 'QFhhOgwz_bgZgOfKFg5XA', - text: 'Engineering Manager > Team Support > Security incident handling', + "id": "6eWgZVLV479oQzl0fu-Od", + "text": "PHP > Style Tools" }, { - id: 'tmY4Ktu6luFg5wKylJW76', - text: 'Engineering Manager > Team Support > Production issues management', + "id": "fSpvZ_4kGFMbFVCWhA8vn", + "text": "PHP > Style Tools > PHPCodeSniffer" }, { - id: 'WYoqfmk5ejB2UOiYXh4Zi', - text: 'Engineering Manager > Partner Management > Vendor relationships', + "id": "r07k_hT2z2EiIBH4q3F7-", + "text": "PHP > Style Tools > PHP CS Fixer" }, { - id: 'xMN575nnnQJeHe2oJYw17', - text: 'Engineering Manager > Partner Management > Technology partnerships', + "id": "PrG_5dyBblXsWYYRcOJMa", + "text": "PHP > Static Analysis" }, { - id: 'f3P0fF4UzgVQZuMVTVmP1', - text: 'Engineering Manager > Partner Management > Integration management', + "id": "12k71gNfwAcT9K5aLWgbZ", + "text": "PHP > Static Analysis > PHPStan" }, { - id: 'ukmMMWacekcejEiEKCLzh', - text: 'Engineering Manager > Partner Management > API strategy', + "id": "T1XD93j6Lkpl88JSmys9b", + "text": "PHP > Static Analysis > Psalm" }, { - id: 'Jctp5tPCK_vY35_bh7QFk', - text: 'Engineering Manager > Partner Management > External collaboration', + "id": "B45YVzov8X_iOtneiFEqa", + "text": "PHP > Static Analysis > Phan" }, { - id: 'QEViLNgG4Uv9Q9PWig0u3', - text: 'Engineering Manager > Customer Relations > Customer feedback integration', + "id": "KC6D81-T-FwQc7Osw1rlY", + "text": "PHP > External Integrations > cURL" }, { - id: 'V5s2i-L2tsZFNxMLN_e_U', - text: 'Engineering Manager > Customer Relations > Technical customer support', + "id": "_Al4NXKVQAnk8OikwvXCL", + "text": "PHP > External Integrations > Guzzle" }, { - id: 'A-Aa7VdDAYfaMUZD_cWwP', - text: 'Engineering Manager > Customer Relations > Customer success alignment', + "id": "SD9k16UlVve9WtNMDA5Za", + "text": "PHP > PHP-FIG" }, { - id: '2QwMcO27H3ygtLlWVplxr', - text: 'Engineering Manager > Customer Relations > Feature prioritization', + "id": "3tONibbRgK7HCwGTE2Gqw", + "text": "PHP > PHP-FIG > PSR Standards" }, { - id: 'tCT2syTMyEHCspDLXxk6R', - text: 'Engineering Manager > Customer Relations > Technical partnerships', + "id": "_Dh78x_tPLqZweg--qZFQ", + "text": "PHP > Performance Optimization > Profiling Techniques" }, { - id: '5MM1ccB1pmQcd3Uyjmbr7', - text: 'Engineering Manager > Executive Communication > Board presentations', + "id": "Av-BMa57RvrLlAXLffOH0", + "text": "PHP > Performance Optimization > Caching Strategies" }, { - id: 'CHothgVl8ulFthwS7uKqK', - text: 'Engineering Manager > Executive Communication > Executive summaries', + "id": "bt7dK2PcOZ72B9HXPyMwL", + "text": "PHP > Performance Optimization > Memory Management" }, { - id: 'uBrsV_EocAkRWEqJYjoZn', - text: 'Engineering Manager > Executive Communication > Strategic proposals', + "id": "VpwwF8j5ZtXVSbzNfE7Sx", + "text": "PHP > Performance Optimization > Configuration Tuning" }, { - id: 'pLUOU2AmAJ9aJAmIlVD7D', - text: 'Engineering Manager > Executive Communication > Budget requests', + "id": "NieqZd1juaNYoZOrB7e31", + "text": "PHP > Performance Optimization > Opcode Caching" }, { - id: 'QssXmeifoI3dtu-eXp8PK', - text: 'Engineering Manager > Executive Communication > Vision alignment', + "id": "AoGS-5MSkp8gtJFQVPSBE", + "text": "PHP > Performance Optimization > PHP-FPM" }, { - id: 'gHhNi32MSBmqk-oKOy-uj', - text: 'Engineering Manager > Knowledge Management > Documentation > Architecture documentation', + "id": "qp5Xi12c0qcSzTanzJq0Z", + "text": "PHP > System Interactions" }, { - id: 'Kwy9O1z2hpeE0Sb3qtxEg', - text: 'Engineering Manager > Knowledge Management > Documentation > Process documentation', + "id": "VhyYNGhOdKKrz_-uTkrjD", + "text": "PHP > System Interactions > Executing System Commands" }, { - id: 'dTjp_rEl1ITZjvELqVtfv', - text: 'Engineering Manager > Knowledge Management > Documentation > Decision records', + "id": "NTKUMgsKGYISIyhgOJPQn", + "text": "PHP > System Interactions > Process Control" }, { - id: '4-MCXFOkMGcN369OPG-vw', - text: 'Engineering Manager > Knowledge Management > Documentation > Best Practices', + "id": "fitjnLYKLHJ2P5G7JAvzm", + "text": "PHP > System Interactions > Environment Variables" }, { - id: '4-MCXFOkMGcN369OPG-vw', - text: 'Engineering Manager > Knowledge Management > Documentation > Best Practices', + "id": "DTaAZaU1CwzW7esoDhj85", + "text": "PHP > System Interactions > Configuration Files" }, { - id: 'HUQ_-vU2pdBPyF0mBocHz', - text: 'Engineering Manager > Knowledge Management > Documentation > Lessons Learned', + "id": "lFoHoMRywCWa056ii5cKQ", + "text": "PHP > Debugging Tools > Xdebug" }, { - id: 'g6K9fxWdRQT5h_u4Y_bkq', - text: 'Engineering Manager > Knowledge Management > Knowledge Transfer > Mentoring Programs', + "id": "KpQb5Zh3GUcbYUyXHvyu2", + "text": "PHP > Debugging Tools > Zend Debugger" }, { - id: '7t9jmv3_lRCEG5y5DA8bF', - text: 'Engineering Manager > Knowledge Management > Knowledge Transfer > Knowledge bases', + "id": "KMQqePqAjQ-ReDwHqeofx", + "text": "PHP > Web Servers > Apache" }, { - id: '2LO0iWf-y3l4rA1n_oG1g', - text: 'Engineering Manager > Knowledge Management > Knowledge Transfer > Tech Talks', - }, - { - id: 'S8-nwYKlG7YHL2dWwR303', - text: 'Engineering Manager > Knowledge Management > Knowledge Transfer > Brown Bags', - }, - { - id: 'QMAIEkVFHrrP6lUWvd0S8', - text: 'Engineering Manager > Change Management > Technical Change > Migration planning', - }, - { - id: '9mNLfntu1TPjcX3RoUeMq', - text: 'Engineering Manager > Change Management > Technical Change > Legacy system retirement', - }, - { - id: 'jerPoyfCcwZbNuE_cl1hq', - text: 'Engineering Manager > Change Management > Technical Change > Technology adoption', - }, - { - id: 'f-52wRfPRrA9iniOMYQB7', - text: 'Engineering Manager > Change Management > Technical Change > Tool transitions', - }, - { - id: 'ev9ZKygqETctLMSt1GAFU', - text: 'Engineering Manager > Change Management > Technical Change > Process changes', - }, - { - id: '1__zRE1iu1FDX9ynpWSBS', - text: 'Engineering Manager > Change Management > Organizational Change > Change strategy', - }, - { - id: 'oGmtkOGVgA4huGJqkBEfj', - text: 'Engineering Manager > Change Management > Organizational Change > Impact assessment', - }, - { - id: '34uOnta7dKOyZL0et_RC8', - text: 'Engineering Manager > Change Management > Organizational Change > Stakeholder management', - }, - { - id: 'Mxi4g_PzT0oYc3NgR0UVg', - text: 'Engineering Manager > Change Management > Organizational Change > Communication planning', - }, - { - id: 'Mxi4g_PzT0oYc3NgR0UVg', - text: 'Engineering Manager > Change Management > Organizational Change > Communication planning', - }, - { - id: 'vfp6VmWnhpre_eDORg7ht', - text: 'Engineering Manager > Change Management > Organizational Change > Resistance management', - }, - { - id: '5_CE3p5jMA1uEqFNfp7Kh', - text: 'Engineering Manager > Change Management > > Reorganizations', - }, - { - id: 'ph0U4l2alVJ8lUJ96q7co', - text: 'Engineering Manager > Change Management > Team Change > Team mergers', - }, - { - id: 'FayHWdUHHYFFBwnXx37Gk', - text: 'Engineering Manager > Change Management > Team Change > Role transitions', - }, - { - id: 'eIlW4mZKNQfBsTDmZf7ex', - text: 'Engineering Manager > Change Management > Team Change > Responsibility shifts', - }, - { - id: 'y7YHIz7OI4sNfC_nhfLcu', - text: 'Engineering Manager > Change Management > Team Change > Culture evolution', - }, + "id": "aspZpACHEKOsi_Er5FYPY", + "text": "PHP > Web Servers > Nginx" + } ]; const OPENAI_API_KEY = process.env.OPENAI_API_KEY; @@ -586,18 +518,17 @@ const prompt = ` You are a helpful assistant that can help me generate content for a roadmap tree. User will give you roadmap topics in the form of "Parent > Child > Leaf". You need to generate content for the last node in the hierarchy in relation to the parents. - Remember that you are describing how an Engineering Manager interacts with or handles - the given topic, not just explaining the topic itself. You may explain why the given - topic is important in an engineering team. Also, I hate it when you say "In the realm of..." + Remember that you are explaining the topics for PHP showing what the given topic is + with respect to PHP and giving a short code sample ONLY when required. + Also, I hate it when you say "In the realm of..." or "In the context of..." or "..in the context of..." or "when we talk about..." or something similar. Content should be helpful and engaging for a technical audience. It can include things like (you can include more or less, depending on the topic): - - How does an Engineering Manager work with or handle this area? - - What are their key responsibilities related to this topic? - - What challenges do they face and how do they address them? - - What skills and approaches are needed to succeed in this aspect? - The content should be a few short textual paragraphs (MAXIMUM 3) that is NO MORE THAN 130 words. + - Briefly explain the given topic in relation to PHP. + - Code sample if applicable. + - Add a link to PHP documentation + The content should be a a single textual paragraph. IMPORTANT: Use simple and clear English. Avoid complex words and jargon when possible. Write in a way that is easy to understand. Use short sentences and common words. `; diff --git a/src/data/roadmaps/php/content/_get@GFYGFVfxkOoPI5mI4zSt1.md b/src/data/roadmaps/php/content/_get@GFYGFVfxkOoPI5mI4zSt1.md index a591a8426..5ccb4c089 100644 --- a/src/data/roadmaps/php/content/_get@GFYGFVfxkOoPI5mI4zSt1.md +++ b/src/data/roadmaps/php/content/_get@GFYGFVfxkOoPI5mI4zSt1.md @@ -1 +1,20 @@ -# $_GET \ No newline at end of file +# $_GET + +$_GET is a pre-defined array in PHP, that's used to collect form-data sent through HTTP GET method. It's useful whenever you need to process or interact with data that has been passed in via a URL's query string. For an example if you have a form with a GET method, you can get the values of the form elements through this global $_GET array. Here’s an example: + +```php +
+``` + +Using $_GET, you can fetch the 'fname' value from the URL: + +```php +echo "Name is: " . $_GET['fname']; +``` + +Visit the following resources to learn more: + +- [@official@PHP Documentation](https://www.php.net/manual/en/reserved.variables.get.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/_post@qNG-a4iIO-puZsMwAMzYC.md b/src/data/roadmaps/php/content/_post@qNG-a4iIO-puZsMwAMzYC.md index a54c695b8..98d9ff4d4 100644 --- a/src/data/roadmaps/php/content/_post@qNG-a4iIO-puZsMwAMzYC.md +++ b/src/data/roadmaps/php/content/_post@qNG-a4iIO-puZsMwAMzYC.md @@ -1 +1,17 @@ -# $_POST \ No newline at end of file +# $_POST + +`$_POST` is a superglobal variable in PHP that's used to collect form data submitted via HTTP POST method. Your PHP script can access this data through `$_POST`. Let's say you have a simple HTML form on your webpage. When the user submits this form, the entered data can be fetched using `$_POST`. Here's a brief example: + +``` + +``` + +In this code, $_POST["name"] fetches the value entered in the 'name' field of the form. Always be cautious when using `$_POST` as it may contain user input which is a common source of vulnerabilities. Always validate and sanitize data from `$_POST` before using it. + +Visit the following resources to learn more: + +- [@official@PHP Documentation](https://www.php.net/manual/en/reserved.variables.post.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/_request@A6rfW4uJhyfAX2b18_EEC.md b/src/data/roadmaps/php/content/_request@A6rfW4uJhyfAX2b18_EEC.md index e2b51afc9..96fc21749 100644 --- a/src/data/roadmaps/php/content/_request@A6rfW4uJhyfAX2b18_EEC.md +++ b/src/data/roadmaps/php/content/_request@A6rfW4uJhyfAX2b18_EEC.md @@ -1 +1,13 @@ -# $_REQUEST \ No newline at end of file +# $_REQUEST + +$_REQUEST is a PHP superglobal variable that contains the contents of both $_GET, $_POST, and $_COOKIE. It is used to collect data sent via both the GET and POST methods, as well as cookies. $_REQUEST is useful if you do not care about the method used to send data, but its usage is generally discouraged as it could lead to security vulnerabilities. Here's a simple example: + +``` +$name = $_REQUEST['name']; +``` + +This statement will store the value of the 'name' field sent through either a GET or POST method. Always remember to sanitize user input to avoid security problems. + +Visit the following resources to learn more: + +- [@official@PHP Documentation](https://www.php.net/manual/en/reserved.variables.request.php) diff --git a/src/data/roadmaps/php/content/_server@7Ja2at_N9tRTlvSGahrqn.md b/src/data/roadmaps/php/content/_server@7Ja2at_N9tRTlvSGahrqn.md index 3fe3ff473..4a97b7ecb 100644 --- a/src/data/roadmaps/php/content/_server@7Ja2at_N9tRTlvSGahrqn.md +++ b/src/data/roadmaps/php/content/_server@7Ja2at_N9tRTlvSGahrqn.md @@ -1 +1,13 @@ -# $_SERVER \ No newline at end of file +# $_SERVER + +The `$_SERVER` is a superglobal in PHP, holding information about headers, paths, and script locations. $_SERVER is an associative array containing server variables created by the web server. This can include specific environmental configurations, the server signature, your PHP script's paths and details, client data, and the active request/response sequence. Among its many uses, `$_SERVER['REMOTE_ADDR']` can help get the visitor's IP while `$_SERVER['HTTP_USER_AGENT']` offers information about their browser. Don't forget to sanitize the content before use to prevent security exploits. + +Here's an easy code sample that prints the client's IP: + +```php +echo 'Your IP is: ' . $_SERVER['REMOTE_ADDR']; +``` + +Visit the following resources to learn more: + +- [@official@PHP Documentation](https://www.php.net/reserved.variables.server) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/abstract-classes@ub79EkMiOmPBwXLRuYFL8.md b/src/data/roadmaps/php/content/abstract-classes@ub79EkMiOmPBwXLRuYFL8.md index afa58dfc0..71d2f5f68 100644 --- a/src/data/roadmaps/php/content/abstract-classes@ub79EkMiOmPBwXLRuYFL8.md +++ b/src/data/roadmaps/php/content/abstract-classes@ub79EkMiOmPBwXLRuYFL8.md @@ -1 +1,7 @@ -# Abstract classes \ No newline at end of file +# Abstract classes + +Abstract classes in PHP are those which cannot be instantiated on their own. They are simply blueprints for other classes, providing a predefined structure. By declaring a class as abstract, you can define methods without having to implement them. Subsequent classes, when inheriting from an abstract class, must implement these undefined methods. + +Visit the following resources to learn more: + +- [@official@PHP Documentation](https://www.php.net/manual/en/language.oop5.abstract.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/access-specifiers@RD2RaBmA2XWkEa13PTCTX.md b/src/data/roadmaps/php/content/access-specifiers@RD2RaBmA2XWkEa13PTCTX.md index 10026602c..aec9d013c 100644 --- a/src/data/roadmaps/php/content/access-specifiers@RD2RaBmA2XWkEa13PTCTX.md +++ b/src/data/roadmaps/php/content/access-specifiers@RD2RaBmA2XWkEa13PTCTX.md @@ -1 +1,7 @@ -# Access Specifiers \ No newline at end of file +# Access Specifiers + +Access specifiers, also known as access modifiers, in PHP are keywords used in the class context which define the visibility and accessibility of properties, methods and constants. PHP supports three types of access specifiers: public, private, and protected. 'Public' specified properties or methods can be accessed from anywhere, 'private' ones can only be accessed within the class that defines them, while 'protected' ones can be accessed within the class itself and by inherited and parent classes. Here's an illustrative example: + +Visit the following resources to learn more: + +- [@official@PHP Documentation](https://www.php.net/manual/en/language.oop5.visibility.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/anonymous-functions@Nr5m6wQLp7VyG3AucrSc8.md b/src/data/roadmaps/php/content/anonymous-functions@Nr5m6wQLp7VyG3AucrSc8.md index df7c2cbd4..9757c6d52 100644 --- a/src/data/roadmaps/php/content/anonymous-functions@Nr5m6wQLp7VyG3AucrSc8.md +++ b/src/data/roadmaps/php/content/anonymous-functions@Nr5m6wQLp7VyG3AucrSc8.md @@ -1 +1,19 @@ -# Anonymous Functions \ No newline at end of file +# Anonymous Functions + +Anonymous functions in PHP, also known as closures, are functions that do not have a specified name. They are most frequently used as a value for callback parameters, but can be used in many other ways. When creating an anonymous function, you can also inherit variables from the parent scope. Here's a basic usage example: + +```php +$greet = function($name) +{ + printf("Hello %s\r\n", $name); +}; + +$greet('World'); +$greet('PHP'); +``` + +In this example, we're creating an anonymous function and assigning it to the variable `$greet`. We then call this anonymous function using $greet with 'World' and 'PHP' as arguments. + +Visit the following resources to learn more: + +- [@official@PHP Documentation - Anonymous Functions](https://www.php.net/manual/en/functions.anonymous.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/apache@KMQqePqAjQ-ReDwHqeofx.md b/src/data/roadmaps/php/content/apache@KMQqePqAjQ-ReDwHqeofx.md index b00666336..5ba2fc5fc 100644 --- a/src/data/roadmaps/php/content/apache@KMQqePqAjQ-ReDwHqeofx.md +++ b/src/data/roadmaps/php/content/apache@KMQqePqAjQ-ReDwHqeofx.md @@ -1 +1,8 @@ -# Apache \ No newline at end of file +# Apache + +Apache is a popular web server that can efficiently host PHP applications. Apache integrates well with PHP, using its `mod_php` module, providing a stable and consistent environment for your PHP scripts to run. This compatibility creates a seamless user experience, as PHP pages are served as if they're part of the website and not just files being executed on the server. + +Visit the following resources to learn more: + +- [@official@PHP Documentations - Apache](https://www.php.net/manual/en/install.unix.apache2.php) +- [@official@Apache Website](https://httpd.apache.org/) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/arrays@IhKjvT6CjRz4dsSU7SNQo.md b/src/data/roadmaps/php/content/arrays@IhKjvT6CjRz4dsSU7SNQo.md index 6bfa7b9a1..44a9c0301 100644 --- a/src/data/roadmaps/php/content/arrays@IhKjvT6CjRz4dsSU7SNQo.md +++ b/src/data/roadmaps/php/content/arrays@IhKjvT6CjRz4dsSU7SNQo.md @@ -1 +1,7 @@ -# Arrays \ No newline at end of file +# Arrays + +Arrays in PHP are fundamental data structures that store multiple elements in a particular key-value pair collection. PHP offers extensive support for arrays, making them convenient for storing sets of data or complex collections. + +Visit the following resources to learn more: + +- [@official@PHP Documentation - Arrays](https://www.php.net/manual/en/language.types.array.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/arrow-functions@mP1BIkqbWVVTU-zZv1ZL6.md b/src/data/roadmaps/php/content/arrow-functions@mP1BIkqbWVVTU-zZv1ZL6.md index b48ca2e4b..3a6df9b29 100644 --- a/src/data/roadmaps/php/content/arrow-functions@mP1BIkqbWVVTU-zZv1ZL6.md +++ b/src/data/roadmaps/php/content/arrow-functions@mP1BIkqbWVVTU-zZv1ZL6.md @@ -1 +1,7 @@ -# Arrow Functions \ No newline at end of file +# Arrow Functions + +Arrow functions provide a more concise syntax to create anonymous functions. The feature enthusiastically borrowed from modern Javascript significantly improves PHP's functional programming credibility. The primary difference between regular PHP closures and PHP Arrow functions is the automatic capturing of variables from the parent scope. + +Visit the following resources to learn more: + +- [@official@PHP Documentation - Arrow Functions](https://www.php.net/manual/en/functions.arrow.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/associative-arrays@i_NRsOJNNp7AOqMgu5Jg8.md b/src/data/roadmaps/php/content/associative-arrays@i_NRsOJNNp7AOqMgu5Jg8.md index 0c03066a0..1e62ad4c3 100644 --- a/src/data/roadmaps/php/content/associative-arrays@i_NRsOJNNp7AOqMgu5Jg8.md +++ b/src/data/roadmaps/php/content/associative-arrays@i_NRsOJNNp7AOqMgu5Jg8.md @@ -1 +1,17 @@ -# Associative Arrays \ No newline at end of file +# Associative Arrays + +Associative arrays in PHP are a type of array that uses named keys instead of numeric ones. This provides a more human-readable way to store data where each value can be accessed by its corresponding string key. An example of an associative array could be storing names as keys and their corresponding ages as values. Here's a brief example: + +```php +$ages = array( + "Peter" => 35, + "John" => 42, + "Mary" => 27 +); +``` + +In this case, to find out John's age, you would simply use `echo $ages['John']` where 'John' is the key. Associative arrays are also easy to loop through using the `foreach` construct. + +Visit the following resources to learn more: + +- [@official@PHP Documentation - Associative Arrays](https://www.php.net/manual/en/language.types.array.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/auth-mechanisms@HJJzKYXdK4BWITLP4APLZ.md b/src/data/roadmaps/php/content/auth-mechanisms@HJJzKYXdK4BWITLP4APLZ.md index 416198734..5685737ce 100644 --- a/src/data/roadmaps/php/content/auth-mechanisms@HJJzKYXdK4BWITLP4APLZ.md +++ b/src/data/roadmaps/php/content/auth-mechanisms@HJJzKYXdK4BWITLP4APLZ.md @@ -1 +1,7 @@ -# Auth Mechanisms \ No newline at end of file +# Auth Mechanisms + +When you are developing PHP application, security should always be a top priority and authentication mechanism forms it's very core. It ensures proper establishing of user identities before they can access your system's resources. PHP provides several methods to implement authentication like session-based, token-based, HTTP authentication, and more. + +Visit the following resources to learn more: + +- [@official@PHP Documentation - Auth Mechanisms](https://www.php.net/manual/en/features.http-auth.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/autoloading@qFiTsf6Es-gwqe6J6bdL1.md b/src/data/roadmaps/php/content/autoloading@qFiTsf6Es-gwqe6J6bdL1.md index 9bdb8b39c..e57805c78 100644 --- a/src/data/roadmaps/php/content/autoloading@qFiTsf6Es-gwqe6J6bdL1.md +++ b/src/data/roadmaps/php/content/autoloading@qFiTsf6Es-gwqe6J6bdL1.md @@ -1 +1,17 @@ -# Autoloading \ No newline at end of file +# Autoloading + +Autoloading is a convenient feature in PHP that allows for automated loading of classes or files when they are needed. For example, if you have a class that is not yet included or required in the script, and you're instantiating that class, PHP would automatically include that class file for you, given that it complies with the standard PHP autoloading conventions. This feature cuts down the need to manually include or require files and makes your code cleaner and more efficient to manage. Here's a simple example: + +```php +spl_autoload_register(function ($class_name) { + include $class_name . '.php'; +}); + +$obj = new MyClass(); +``` + +In this example, PHP will automatically load the MyClass.php file when the MyClass is instantiated. + +Visit the following resources to learn more: + +- [@official@PHP Documentation - Autloading](https://www.php.net/manual/en/language.oop5.autoload.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/basic-php-syntax@hzBUHSuFwLYNooF_vEmrs.md b/src/data/roadmaps/php/content/basic-php-syntax@hzBUHSuFwLYNooF_vEmrs.md index be6a923d1..514669404 100644 --- a/src/data/roadmaps/php/content/basic-php-syntax@hzBUHSuFwLYNooF_vEmrs.md +++ b/src/data/roadmaps/php/content/basic-php-syntax@hzBUHSuFwLYNooF_vEmrs.md @@ -1 +1,7 @@ -# Basic PHP Syntax \ No newline at end of file +# Basic PHP Syntax + +PHP syntax is generally considered similar to C-style syntax, where code blocks are defined with curly braces, variables start with a dollar sign ($), and statements end with a semicolon (;), making it relatively easy to learn for programmers familiar with C-like languages; PHP scripts are embedded within HTML using opening tags "" to mark where PHP code should be executed within a web page. + +Visit the following resources to learn more: + +- [@official@PHP Documentation - Basic Syntax](https://www.php.net/manual/en/langref.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/caching-strategies@Av-BMa57RvrLlAXLffOH0.md b/src/data/roadmaps/php/content/caching-strategies@Av-BMa57RvrLlAXLffOH0.md index 7b2bb1441..a5ef0053e 100644 --- a/src/data/roadmaps/php/content/caching-strategies@Av-BMa57RvrLlAXLffOH0.md +++ b/src/data/roadmaps/php/content/caching-strategies@Av-BMa57RvrLlAXLffOH0.md @@ -1 +1,7 @@ -# Caching Strategies \ No newline at end of file +# Caching Strategies + +Caching Strategies are integral to Performance Optimization in PHP. Caching minimizes server load and enhances application speed by temporarily storing results of expensive operations, so that they can be reused in subsequent requests. Some caching techniques used in PHP include opcode caching, object caching, database query caching or full-page caching. For example, OPcache is an opcode caching system that improves PHP performance by storing precompiled script bytecode in memory, negating the need for PHP to load and parse scripts on every request. + +Visit the following resources to learn more: + +- [@official@Official Documentation - Opcache](https://www.php.net/manual/en/book.opcache.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/callback-functions@x7hA2KAzJIjc-prgCEw6V.md b/src/data/roadmaps/php/content/callback-functions@x7hA2KAzJIjc-prgCEw6V.md index e09de7ad4..c056c291c 100644 --- a/src/data/roadmaps/php/content/callback-functions@x7hA2KAzJIjc-prgCEw6V.md +++ b/src/data/roadmaps/php/content/callback-functions@x7hA2KAzJIjc-prgCEw6V.md @@ -1 +1,7 @@ -# Callback Functions \ No newline at end of file +# Callback Functions + +A callback function will use that function on whatever data is returned by a particular method. + +Visit the following resources to learn more: + +- [@official@Official Documentation - Callback functions](https://www.php.net/manual/en/language.types.callable.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/casting-data-types@pzReF4C0mcCWAnpfIJbwl.md b/src/data/roadmaps/php/content/casting-data-types@pzReF4C0mcCWAnpfIJbwl.md index ad65fcbe1..db71ee410 100644 --- a/src/data/roadmaps/php/content/casting-data-types@pzReF4C0mcCWAnpfIJbwl.md +++ b/src/data/roadmaps/php/content/casting-data-types@pzReF4C0mcCWAnpfIJbwl.md @@ -1 +1,7 @@ -# Casting Data Types \ No newline at end of file +# Casting Data Types + +PHP, as a loose typing language, allows us to change the type of a variable or to transform an instance of one data type into another. This operation is known as Casting. When to use casting, however, depends on the situation - it is recommendable when you want explicit control over the data type for an operation. The syntax involves putting the intended type in parentheses before the variable. For example, if you wanted to convert a string to an integer, you'd use: `$myVar = "123"; $intVar = (int) $myVar;`. Here, `$intVar` would be an integer representation of `$myVar`. Remember, the original variable type remains unchanged. + +Visit the following resources to learn more: + +- [@official@Official Documentation - Type Casting](https://www.php.net/manual/en/language.types.type-juggling.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/classes-and-objects@PIuplWreo7PFG3Mdn2t6W.md b/src/data/roadmaps/php/content/classes-and-objects@PIuplWreo7PFG3Mdn2t6W.md index 4ab88d34b..255ce7044 100644 --- a/src/data/roadmaps/php/content/classes-and-objects@PIuplWreo7PFG3Mdn2t6W.md +++ b/src/data/roadmaps/php/content/classes-and-objects@PIuplWreo7PFG3Mdn2t6W.md @@ -1 +1,7 @@ -# Classes and Objects \ No newline at end of file +# Classes and Objects + +PHP supports object-oriented programming, offering a multi-paradigm way of coding through classes and objects. A class is like a blueprint for creating objects that encapsulate all faculties, properties and methods. An object, on the other hand, is an instance of a class where you can interact with the class's methods and change its properties. PHP lets you define a class using the keyword 'class', set properties and methods within it, and then create an object of that class using 'new'. + +Visit the following resources to learn more: + +- [@official@PHP Documentation - Classes](https://www.php.net/manual/en/language.oop5.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/composer@yVFDu2aTiEZ4PWMdKdW2P.md b/src/data/roadmaps/php/content/composer@yVFDu2aTiEZ4PWMdKdW2P.md index 9a8247bff..61b2ed309 100644 --- a/src/data/roadmaps/php/content/composer@yVFDu2aTiEZ4PWMdKdW2P.md +++ b/src/data/roadmaps/php/content/composer@yVFDu2aTiEZ4PWMdKdW2P.md @@ -1 +1,13 @@ -# Composer \ No newline at end of file +# Composer + +Composer is a fundamental tool in modern PHP development. It simplifies the management of project dependencies, allowing you to declare what you need and automatically installing those resources in your project. For example, if your PHP project requires a certain library, Composer will fetch the appropriate version and make sure it's available for your project. Here's an example of how to add a dependency using Composer: + +```shell +composer require vendor/package +``` + +This command adds the `vendor/package` dependency to your project. The same goes for removing dependencies, updating them, and more. + +Visit the following resources to learn more: + +- [@official@Composer Official Website](https://getcomposer.org/doc/) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/conditionals@38YksjvhXCbgnHqkl57Cz.md b/src/data/roadmaps/php/content/conditionals@38YksjvhXCbgnHqkl57Cz.md index e36a33870..bb25d77a7 100644 --- a/src/data/roadmaps/php/content/conditionals@38YksjvhXCbgnHqkl57Cz.md +++ b/src/data/roadmaps/php/content/conditionals@38YksjvhXCbgnHqkl57Cz.md @@ -1 +1,7 @@ -# Conditionals \ No newline at end of file +# Conditionals + +Conditionals in PHP, much like in other programming languages, allow for branching in code, meaning your program can choose to execute specific parts of code based on the state of variables or expressions. The most common conditional statements in PHP are "if", "else", and "elseif". + +Visit the following resources to learn more: + +- [@official@Official Documentation - Control Structures](https://www.php.net/manual/en/language.control-structures.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/configuration-files@DTaAZaU1CwzW7esoDhj85.md b/src/data/roadmaps/php/content/configuration-files@DTaAZaU1CwzW7esoDhj85.md index b7afab188..76e1b8ffb 100644 --- a/src/data/roadmaps/php/content/configuration-files@DTaAZaU1CwzW7esoDhj85.md +++ b/src/data/roadmaps/php/content/configuration-files@DTaAZaU1CwzW7esoDhj85.md @@ -1 +1,7 @@ -# Configuration Files \ No newline at end of file +# Configuration Files + +Configuration files are critical for PHP applications because they help manage dynamic settings like database connection information, error reporting, and many other PHP settings without hard coding, making your application flexible and secure. PHP uses an "php.ini" file to hold these settings. You can modify settings by accessing and changing values in this file. For example, to adjust the maximum file upload size, you might modify the `upload_max_filesize` directive. However, changes to the `php.ini` file take effect only after the server is restarted. + +Visit the following resources to learn more: + +- [@official@Official Documentation - PHP Config](https://www.php.net/manual/en/ini.list.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/configuration-tuning@VpwwF8j5ZtXVSbzNfE7Sx.md b/src/data/roadmaps/php/content/configuration-tuning@VpwwF8j5ZtXVSbzNfE7Sx.md index 258f07b86..5946379d4 100644 --- a/src/data/roadmaps/php/content/configuration-tuning@VpwwF8j5ZtXVSbzNfE7Sx.md +++ b/src/data/roadmaps/php/content/configuration-tuning@VpwwF8j5ZtXVSbzNfE7Sx.md @@ -1 +1,15 @@ -# Configuration Tuning \ No newline at end of file +# Configuration Tuning + +For performance optimization in PHP, configuration tuning is a crucial step. You can manipulate several settings in your php.ini file to enhance your PHP application's performance. For instance, `memory_limit` is a key parameter that specifies the maximum amount of memory a script can consume. Optimizing this setting will prevent the PHP scripts from eating up all server resources. Similarly, adjusting the `max_execution_time` limits the time a script runs. Just ensure careful configuration since restrictive settings could lead to issues. Here's a simple example of how you might modify these parameters: + +```php +// Updating memory_limit +ini_set('memory_limit','256M'); + +// Updating max_execution_time +ini_set('max_execution_time', '300'); +``` + +Visit the following resources to learn more: + +- [@official@Official Documentation - PHP.ini](https://www.php.net/manual/en/ini.core.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/connection-pooling@txUyPR_tdC8iTJV3RtvBz.md b/src/data/roadmaps/php/content/connection-pooling@txUyPR_tdC8iTJV3RtvBz.md index 8afbbfd46..79f7fc25f 100644 --- a/src/data/roadmaps/php/content/connection-pooling@txUyPR_tdC8iTJV3RtvBz.md +++ b/src/data/roadmaps/php/content/connection-pooling@txUyPR_tdC8iTJV3RtvBz.md @@ -1 +1,5 @@ -# Connection Pooling \ No newline at end of file +# Connection Pooling + +Connection pooling is a technique used in PHP to manage and maintain multiple open connections with a database. It reduces the time overhead of constantly opening and closing connections, and ensures efficient utilisation of resources. Connection pooling limits the number of connections opened with the database and instead reuses a pool of existing active connections, thereby significantly enhancing the performance of PHP applications. When a PHP script needs to communicate with the database, it borrows a connection from this pool, performs the operations, and then returns it back to the pool. Although PHP doesn't have native support for connection pooling, it can be achieved through third-party tools like 'pgBouncer' when using PostgreSQL or 'mysqlnd_ms' plugin with MySQL. Note, it's recommended to use connection pooling when you've a high-traffic PHP application. + +For more information, visit PHP Database Extensions [here](https://www.php.net/manual/en/refs.database.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/constants@VLRLymQmLfscrBfzXKvHi.md b/src/data/roadmaps/php/content/constants@VLRLymQmLfscrBfzXKvHi.md index bc0ec2635..0a2b9ad13 100644 --- a/src/data/roadmaps/php/content/constants@VLRLymQmLfscrBfzXKvHi.md +++ b/src/data/roadmaps/php/content/constants@VLRLymQmLfscrBfzXKvHi.md @@ -1 +1,10 @@ -# Constants \ No newline at end of file +# Constants + +Constants in PHP are fixed values that do not change during the execution of the script. They can be handy for values that need to be reused often like a website's URL, a company's name, or even a hardcoded database connection string. Unlike variables, once a constant is defined, it cannot be undefined or reassigned. Constants are case-sensitive by default but this can be overridden. They are defined using the define() function or the const keyword. For instance, you can create a constant to hold the value of Pi and call it in your script like this: + +```php +define("PI", 3.14); +echo PI; // Outputs: 3.14 +``` + +For more information, visit the PHP documentation on constants [here](https://www.php.net/manual/en/language.constants.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/constructor--destructor@oNUt1oT8pYBVvH0S2P6cb.md b/src/data/roadmaps/php/content/constructor--destructor@oNUt1oT8pYBVvH0S2P6cb.md index f5dfb6be5..f04149369 100644 --- a/src/data/roadmaps/php/content/constructor--destructor@oNUt1oT8pYBVvH0S2P6cb.md +++ b/src/data/roadmaps/php/content/constructor--destructor@oNUt1oT8pYBVvH0S2P6cb.md @@ -1 +1,26 @@ -# Constructor / Destructor \ No newline at end of file +# Constructor / Destructor + +Constructor and Destructor methods are fundamental components of Object-Oriented Programming (OOP) in PHP. A constructor is a special type of method that automatically runs upon creating an object, often used to set property values or default behaviors. On the other hand, a destructor is a method that is automatically invoked when an object is due to be destroyed, perfect for cleanup activities. Here is a basic example: + +```php +class TestClass { + public $value; + + // Constructor Method + public function __construct($val) { + $this->value = $val; + } + + // Destructor Method + public function __destruct() { + echo "Object is being destroyed."; + } +} + +$obj = new TestClass("Hello World"); +echo $obj->value; +// Displays: Hello World +// And when the script ends, "Object is being destroyed." +``` + +Visit [PHP Constructors and Destructors](https://www.php.net/manual/en/language.oop5.decon.php) for a more detailed look at these vital concepts. \ No newline at end of file diff --git a/src/data/roadmaps/php/content/cookies@so03-fK7E2WvTm6XsPq4i.md b/src/data/roadmaps/php/content/cookies@so03-fK7E2WvTm6XsPq4i.md index 473563ee0..48b7182c3 100644 --- a/src/data/roadmaps/php/content/cookies@so03-fK7E2WvTm6XsPq4i.md +++ b/src/data/roadmaps/php/content/cookies@so03-fK7E2WvTm6XsPq4i.md @@ -1 +1,3 @@ -# Cookies \ No newline at end of file +# Cookies + +Cookies are a crucial part of state management in PHP. They enable storage of data on the user's browser, which can then be sent back to the server with each subsequent request. This permits persistent data between different pages or visits. To set a cookie in PHP, you can use the `setcookie()` function. For example, `setcookie("user", "John Doe", time() + (86400 * 30), "/");` will set a cookie named "user" with the value "John Doe", that will expire after 30 days. The cookie will be available across the entire website due to the path parameter set as `/`. To retrieve the value of the cookie, you can use the global `$_COOKIE` array: `echo $_COOKIE["user"];`. For more detailed information, you can visit [PHP's official documentation on cookies](https://www.php.net/manual/en/features.cookies.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/csrf-protection@J9yIXZTtwbFzH2u4dI1ep.md b/src/data/roadmaps/php/content/csrf-protection@J9yIXZTtwbFzH2u4dI1ep.md index 69b02618a..afe3d9c50 100644 --- a/src/data/roadmaps/php/content/csrf-protection@J9yIXZTtwbFzH2u4dI1ep.md +++ b/src/data/roadmaps/php/content/csrf-protection@J9yIXZTtwbFzH2u4dI1ep.md @@ -1 +1,19 @@ -# CSRF Protection \ No newline at end of file +# CSRF Protection + +Cross-Site Request Forgery (CSRF) Protection in PHP is a method where a website can defend itself against unwanted actions performed on behalf of the users without their consent. It's a critical aspect of security as it safeguards users against potential harmful activities. Here's an example: if users are logged into a website and get tricked into clicking a deceitful link, CSRF attacks could be triggered. To protect your PHP applications from such attacks, you can generate a unique token for every session and include it as a hidden field for all form submissions. Afterwards, you need to verify this token on the server side before performing any action. + +``` + +``` + +Edge cases like AJAX requests and applications running across multiple domains require extra considerations. More about CSRF can be found in the [PHP Security Guide](https://php.net/manual/en/security.csrf.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/csv-processing@MRDjEjbkMpk7shcWAoPOF.md b/src/data/roadmaps/php/content/csv-processing@MRDjEjbkMpk7shcWAoPOF.md index 861222acb..69867f40c 100644 --- a/src/data/roadmaps/php/content/csv-processing@MRDjEjbkMpk7shcWAoPOF.md +++ b/src/data/roadmaps/php/content/csv-processing@MRDjEjbkMpk7shcWAoPOF.md @@ -1 +1,14 @@ -# CSV Processing \ No newline at end of file +# CSV Processing + +CSV processing refers to handling CSV (Comma Separated Values) files in PHP, an operation significantly useful for managing tabular data. PHP provides a few key functions to handle CSV files effectively. For example, `fgetcsv()` allows you to read CSV file line by line, `fputcsv()` lets you write line by line into a CSV file, and `str_getcsv()` allows you to parse a CSV string into an array. A quick example of reading a CSV file: + +```php +if (($handle = fopen("sample.csv", "r")) !== FALSE) { + while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { + print_r($data); + } + fclose($handle); +} +``` + +In this snippet, PHP reads through each line of the `sample.csv` file, converting each into an array with `fgetcsv()`. You can study more about CSV processing in PHP via the official [PHP documentation](https://php.net/manual/en/ref.fileinfo.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/curl@KC6D81-T-FwQc7Osw1rlY.md b/src/data/roadmaps/php/content/curl@KC6D81-T-FwQc7Osw1rlY.md index d4b657b2f..430284f7c 100644 --- a/src/data/roadmaps/php/content/curl@KC6D81-T-FwQc7Osw1rlY.md +++ b/src/data/roadmaps/php/content/curl@KC6D81-T-FwQc7Osw1rlY.md @@ -1 +1,19 @@ -# cURL \ No newline at end of file +# cURL + +cURL is a flexible way to make requests to external servers from within a PHP script. cURL, which stands for Client URL, is a library that facilitates various types of network communication methods based on different types of URLs. You can, for example, use cURL functions in PHP to access REST APIs, download files, or post form data, among other things. Here's a basic PHP cURL example where we fetch data from an API: + +```php +$ch = curl_init(); + +curl_setopt($ch, CURLOPT_URL, "http://example.com/api/data"); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + +$result = curl_exec($ch); + +if(curl_errno($ch)){ + echo 'Error:' . curl_error($ch); +} + +curl_close($ch); +``` +In this code, we initialize a cURL session, set its options, execute it, then close the session. We also included error handling. PHP's cURL functions are documented in detail at [PHP.net](https://www.php.net/manual/en/book.curl.php). diff --git a/src/data/roadmaps/php/content/data-types@srIHPZabaCGdB5VvUXaMa.md b/src/data/roadmaps/php/content/data-types@srIHPZabaCGdB5VvUXaMa.md index c8efc9c3d..1c399c789 100644 --- a/src/data/roadmaps/php/content/data-types@srIHPZabaCGdB5VvUXaMa.md +++ b/src/data/roadmaps/php/content/data-types@srIHPZabaCGdB5VvUXaMa.md @@ -1 +1,12 @@ -# Data Types \ No newline at end of file +# Data Types + +PHP is a flexible and widely-used language that supports several types of data. These types include integers, floating-point numbers, strings, arrays, objects, NULL, and many more. The different data types allow developers to efficiently manage and handle data in their applications. For example, an integer data type in PHP can be a non-decimal number between -2,147,483,648 and 2,147,483,647. Here's a small sample PHP code snippet that assigns different data types to variables: + +```php +$text = "Hello world!"; // String +$number = 1234; // Integer +$decimalNumber = 12.34; // Floating-point number +$boolean = true; // Boolean +``` + +For a deeper dive into PHP's data types, you can check out the official [PHP documentation](https://www.php.net/manual/en/language.types.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/database-migrations@meplwvmHMtI3Sb_fyodzZ.md b/src/data/roadmaps/php/content/database-migrations@meplwvmHMtI3Sb_fyodzZ.md index 5aea99e93..ab5ab9077 100644 --- a/src/data/roadmaps/php/content/database-migrations@meplwvmHMtI3Sb_fyodzZ.md +++ b/src/data/roadmaps/php/content/database-migrations@meplwvmHMtI3Sb_fyodzZ.md @@ -1 +1,3 @@ -# Database Migrations \ No newline at end of file +# Database Migrations + +Database migrations help keep track of changes in your database schema, making it easier to move from one version of a database to another. Migrations allow us to evolve our database design iteratively and apply these updates across our development, staging, and production servers. This can save a lot of manual work. But more than that, migrations maintain consistency across all the environments, reducing the chances of unexpected behavior. There's no standard built-in migrations mechanism in PHP, but powerful and popular PHP frameworks like Laravel have robust solutions for migrations. Check out the [Laravel's migrations documentation](https://laravel.com/docs/migrations). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/database-transactions@FY-F6n9j29hQrnFry3VGb.md b/src/data/roadmaps/php/content/database-transactions@FY-F6n9j29hQrnFry3VGb.md index 04eeb00f9..41329d57a 100644 --- a/src/data/roadmaps/php/content/database-transactions@FY-F6n9j29hQrnFry3VGb.md +++ b/src/data/roadmaps/php/content/database-transactions@FY-F6n9j29hQrnFry3VGb.md @@ -1 +1,7 @@ -# Database Transactions \ No newline at end of file +# Database Transactions + +Database transactions in PHP refer to a unit of work performed within a database system, which is treated in a coordinated manner. This technique is vital when dealing with critical tasks like money transfer between accounts, where data consistency is crucial. If one part of the transaction fails, the entire transaction fails, ensuring that the database stays consistent even in an event of a failure. + +Visit the following resources to learn more: + +- [@official@PHP Documentation - PDO Transactions](https://www.php.net/manual/en/pdo.transactions.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/default--optional-params@RgVP99rJJ8FVecIA45w20.md b/src/data/roadmaps/php/content/default--optional-params@RgVP99rJJ8FVecIA45w20.md index bd452d089..d5bcdd968 100644 --- a/src/data/roadmaps/php/content/default--optional-params@RgVP99rJJ8FVecIA45w20.md +++ b/src/data/roadmaps/php/content/default--optional-params@RgVP99rJJ8FVecIA45w20.md @@ -1 +1,14 @@ -# Default / Optional Params \ No newline at end of file +# Default / Optional Params + +In PHP, you can assign default values to your function parameters. These are called default or optional parameters. This is exceptionally useful when you want to make the function argument optional so if a value is not provided when the function is called, then the default value is used instead. Here's a simple code example: + +```php +function greet($name = "guest") { + echo "Hello, $name!"; +} + +greet(); // Outputs: Hello, guest! +greet("John"); // Outputs: Hello, John! +``` + +In this example, the `greet` function has a default value of "guest" for the `$name` parameter. So, if no argument is given while calling `greet`, it defaults to greet a "guest". If an argument is provided, like `John`, it overrides the default value. Follow this [link](https://www.php.net/manual/en/functions.arguments.php#functions.arguments.default) for the PHP documentation on function arguments. \ No newline at end of file diff --git a/src/data/roadmaps/php/content/dependency-injection@KEE50C6lOS4eX8sAbfhYe.md b/src/data/roadmaps/php/content/dependency-injection@KEE50C6lOS4eX8sAbfhYe.md index 450bde1c7..fa14599c1 100644 --- a/src/data/roadmaps/php/content/dependency-injection@KEE50C6lOS4eX8sAbfhYe.md +++ b/src/data/roadmaps/php/content/dependency-injection@KEE50C6lOS4eX8sAbfhYe.md @@ -1 +1,29 @@ -# Dependency injection \ No newline at end of file +# Dependency injection + +Dependency injection is a design pattern used mainly for managing class dependencies. Here, instead of a class being responsible for creating its dependencies on its own, an injector (the "client") passes the requirements to the class (the "service"), centralizing control and encouraging code to follow the single responsibility principle. As a simple example, consider a situation where class B needs to utilize class A's methods. Instead of creating an object of class A within B, with dependency injection, we pass an instance of class A to B. + +```php +class A { + function display(){ + echo 'Hello, PHP dependency injection!'; + } +} + +class B { + private $a; + + public function __construct(A $classAInstance) { + $this->a = $classAInstance; + } + + public function callDisplayOwn() { + $this->a->display(); + } +} + +$instanceA = new A(); +$instanceB = new B($instanceA); +$instanceB->callDisplayOwn(); // Outputs: "Hello, PHP dependency injection!" +``` + +More details can be found on [PHP Documentation](https://www.php.net/manual/en/language.oop5.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/echo@2ykzBBdYhWuM-neGf0AWP.md b/src/data/roadmaps/php/content/echo@2ykzBBdYhWuM-neGf0AWP.md index 0a3325979..bd573edb9 100644 --- a/src/data/roadmaps/php/content/echo@2ykzBBdYhWuM-neGf0AWP.md +++ b/src/data/roadmaps/php/content/echo@2ykzBBdYhWuM-neGf0AWP.md @@ -1 +1,11 @@ -# echo \ No newline at end of file +# echo + +'echo' is a language construct in PHP, and it is commonly used to output one or more strings to the browser. This command doesn't behave like a function, hence it doesn't require parentheses unless it's necessary to avoid confusion. Check out a simple example below where we are using echo to output a simple string: + +```php +echo "Hello, world!"; +``` + +This will indeed output: Hello, world! + +It's also worth mentioning that 'echo' also supports multiple parameters. The PHP official documentation provides more detailed information: [PHP: echo](https://www.php.net/manual/en/function.echo.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/environment-variables@fitjnLYKLHJ2P5G7JAvzm.md b/src/data/roadmaps/php/content/environment-variables@fitjnLYKLHJ2P5G7JAvzm.md index be8e682f7..b91aa94df 100644 --- a/src/data/roadmaps/php/content/environment-variables@fitjnLYKLHJ2P5G7JAvzm.md +++ b/src/data/roadmaps/php/content/environment-variables@fitjnLYKLHJ2P5G7JAvzm.md @@ -1 +1,15 @@ -# Environment Variables \ No newline at end of file +# Environment Variables + +Environment variables provide a way to influence the behavior of software on your system. They consist of name/value pairs and are used for various purposes, such as to specify directory paths, usernames, or passwords that your PHP application might use. You can set PHP environment variables using the `putenv()` function, and retrieve them using `getenv()`. For example, if you want to set the environment variable "FOO" to "bar", you could do so like this: + +```php +putenv("FOO=bar"); +``` + +And then you can retrieve the value with `getenv()` like: + +```php +echo getenv("FOO"); // returns "bar" +``` + +Keep in mind that environment variables set using `putenv()` are only available for the duration of the current request. If you want them to persist for future requests, you'll need to set them using your system's method for setting environment variables. More on this at the [official PHP documentation](https://www.php.net/manual/en/function.putenv.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/evolution-and-history@b2CuLrhsUNnb4OxI6RRAS.md b/src/data/roadmaps/php/content/evolution-and-history@b2CuLrhsUNnb4OxI6RRAS.md index bdbafdf9d..272aa3c0b 100644 --- a/src/data/roadmaps/php/content/evolution-and-history@b2CuLrhsUNnb4OxI6RRAS.md +++ b/src/data/roadmaps/php/content/evolution-and-history@b2CuLrhsUNnb4OxI6RRAS.md @@ -1 +1,3 @@ -# Evolution and History \ No newline at end of file +# Evolution and History + +PHP, originally standing for Personal Home Page, is a popular scripting language used commonly for web development. Rasmus Lerdorf created it in 1994, and since then, it has evolved significantly from a simple set of CGI binaries written in C, to a full-featured language. PHP's journey includes several versions, with PHP 3 introducing a re-written parser and a better approach to object-oriented programming. PHP 8.0, introduced several optimizations, JIT compilation, and union types, among other improvements. For more details on PHP's history, check out the official PHP documentation [here](https://www.php.net/history). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/executing-system-commands@VhyYNGhOdKKrz_-uTkrjD.md b/src/data/roadmaps/php/content/executing-system-commands@VhyYNGhOdKKrz_-uTkrjD.md index bb167237a..eabaed675 100644 --- a/src/data/roadmaps/php/content/executing-system-commands@VhyYNGhOdKKrz_-uTkrjD.md +++ b/src/data/roadmaps/php/content/executing-system-commands@VhyYNGhOdKKrz_-uTkrjD.md @@ -1 +1,15 @@ -# Executing System Commands \ No newline at end of file +# Executing System Commands + +PHP provides developers with the flexibility to invoke system commands directly from PHP scripts. This can be achieved with functions like `exec()`, `system()`, or `passthru()`, which allow your PHP script to execute system-level instructions and interact with the underlying server. This can be useful in several scenarios - for automating tasks, orchestrating system activities, or even for pulling out system information. However, it's important to use these functions with caution due to the security risks of executing system commands. Here's a simple example of using the exec() function: + +```php + +``` + +The above script runs the 'ls' command that lists all files and directories in the current folder. For more details, check out the official PHP documentation [here](https://www.php.net/manual/en/ref.exec.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/file-permissions@tgIyG6vHWpe9sz6lHmj5a.md b/src/data/roadmaps/php/content/file-permissions@tgIyG6vHWpe9sz6lHmj5a.md index 8fb3a2c6c..6e45defb5 100644 --- a/src/data/roadmaps/php/content/file-permissions@tgIyG6vHWpe9sz6lHmj5a.md +++ b/src/data/roadmaps/php/content/file-permissions@tgIyG6vHWpe9sz6lHmj5a.md @@ -1 +1,3 @@ -# File Permissions \ No newline at end of file +# File Permissions + +File permissions in PHP control who can read, write, and execute a file. They're crucial for the security and proper functioning of your PHP applications. When working with files, you can use functions like `chmod()`, `is_readable()`, and `is_writable()` to manage permissions. Typically, you would use `chmod()` to change the permissions of a file. The first parameter is the name of the file and the second parameter is the mode. For instance, `chmod($file, 0755)` would assign owner permissions to read, write, and execute, while everyone else would only have read and execute permissions. To know if a file is readable or writable, use `is_readable()` or `is_writable()` respectively. Each returns a Boolean value. To learn more, check out PHP's official [documentation on filesystem functions.](https://www.php.net/manual/en/ref.filesystem.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/file-uploads@HNo8QO4aPbvgePiA4l6tq.md b/src/data/roadmaps/php/content/file-uploads@HNo8QO4aPbvgePiA4l6tq.md index 54a3d9089..e8a1faba1 100644 --- a/src/data/roadmaps/php/content/file-uploads@HNo8QO4aPbvgePiA4l6tq.md +++ b/src/data/roadmaps/php/content/file-uploads@HNo8QO4aPbvgePiA4l6tq.md @@ -1 +1,5 @@ -# File Uploads \ No newline at end of file +# File Uploads + +Uploading files in PHP is a commonly used functionality for many applications. This is typically done using the `$_FILES` superglobal array that allows you to manage uploaded files in your PHP script. It contains details like `name`, `type`, `size` etc of the file. An index is also present for each file in the case of multiple uploads. The `move_uploaded_file()` function is then used to move the uploaded file to the desired directory. + +Don't forget to pay attention to security considerations when accepting file uploads. For comprehensive details, you can refer to the PHP documentation [here](https://www.php.net/manual/en/features.file-upload.php). diff --git a/src/data/roadmaps/php/content/form-processing@sYI7f1PYP7G30_Uj2mZRv.md b/src/data/roadmaps/php/content/form-processing@sYI7f1PYP7G30_Uj2mZRv.md index 15dde4c1f..8275b36e8 100644 --- a/src/data/roadmaps/php/content/form-processing@sYI7f1PYP7G30_Uj2mZRv.md +++ b/src/data/roadmaps/php/content/form-processing@sYI7f1PYP7G30_Uj2mZRv.md @@ -1 +1,5 @@ -# Form Processing \ No newline at end of file +# Form Processing + +Form processing is a common web function and in PHP, it's pretty straightforward. It typically involves accepting data from a user through a web form and then using PHP to handle, process and possibly store that data. PHP provides superglobal arrays (`$_GET`, `$_POST`, and `$_REQUEST`) which help to collect form data. Let's talk about a simple example of a form that accepts a name from a user and then displays it. + +Make sure to handle form data securely, for instance by using the `htmlspecialchars()` function to neutralize any harmful characters. More information about form processing in PHP can be found in the PHP [documentation](https://www.php.net/manual/en/tutorial.forms.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/function-declaration@1nODJchgSuWbcvSlxnWeE.md b/src/data/roadmaps/php/content/function-declaration@1nODJchgSuWbcvSlxnWeE.md index cd60b1fdf..8e81b0484 100644 --- a/src/data/roadmaps/php/content/function-declaration@1nODJchgSuWbcvSlxnWeE.md +++ b/src/data/roadmaps/php/content/function-declaration@1nODJchgSuWbcvSlxnWeE.md @@ -1 +1,11 @@ -# Function Declaration \ No newline at end of file +# Function Declaration + +Function is the block of code that performs a specific task. It is a reusable code that can be called multiple times. In PHP, a function is declared using the `function` keyword followed by the function name and parentheses. The function name should be unique and descriptive. The parentheses may contain parameters that are passed to the function. The function body is enclosed within curly braces `{}`. + +```php +function greeting($name) { + echo "Hello, " . $name; +} +``` + +In this case, 'greeting' is the function name, '$name' is the parameter, and 'echo "Hello, " . $name;' is the operation. To learn more, you can refer to the [PHP Documentation](https://www.php.net/manual/en/functions.user-defined.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/functions@WiGv7vi7Mtw-YqPMcnnyw.md b/src/data/roadmaps/php/content/functions@WiGv7vi7Mtw-YqPMcnnyw.md index cebcc2697..8dff50856 100644 --- a/src/data/roadmaps/php/content/functions@WiGv7vi7Mtw-YqPMcnnyw.md +++ b/src/data/roadmaps/php/content/functions@WiGv7vi7Mtw-YqPMcnnyw.md @@ -1 +1,13 @@ -# Functions \ No newline at end of file +# Functions + +Functions in PHP are self-contained blocks of code that carry out specific tasks and can be reused throughout your application. A function is defined with the word "function" followed by a name, and it should return a value using the "return" statement. To use a function, you simply need to call it by its name. You can also pass parameters to functions to influence how they work. Here's a simple function: + +```php +function greet($name) { + return "Hello, " . $name; +} + +echo greet("John"); // Outputs: Hello, John +``` + +In the code above, "greet" is a function that takes one parameter "name". It concatenates "Hello, " with the name and returns the result. For more on PHP functions, visit the PHP documentation at [php.net](https://www.php.net/manual/en/language.functions.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/guzzle@_Al4NXKVQAnk8OikwvXCL.md b/src/data/roadmaps/php/content/guzzle@_Al4NXKVQAnk8OikwvXCL.md index f73258e88..b60182230 100644 --- a/src/data/roadmaps/php/content/guzzle@_Al4NXKVQAnk8OikwvXCL.md +++ b/src/data/roadmaps/php/content/guzzle@_Al4NXKVQAnk8OikwvXCL.md @@ -1 +1,5 @@ -# Guzzle \ No newline at end of file +# Guzzle + +Guzzle is a PHP HTTP client that simplifies making HTTP requests in PHP. It provides a straightforward and powerful way to send HTTP requests. Guzzle can simplify your life if you often handle APIs or other HTTP requests. It's great for everything from sending simple GET requests, to uploading files with POST requests, or even handling Errors using exception handling. + +For in-depth usage and more examples, you should check out the [official Guzzle documentation](http://docs.guzzlephp.org/en/stable/). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/http-methods@tn_iIfaJZVtPK6vFds7FH.md b/src/data/roadmaps/php/content/http-methods@tn_iIfaJZVtPK6vFds7FH.md index 84d6b9924..9371d8b2c 100644 --- a/src/data/roadmaps/php/content/http-methods@tn_iIfaJZVtPK6vFds7FH.md +++ b/src/data/roadmaps/php/content/http-methods@tn_iIfaJZVtPK6vFds7FH.md @@ -1 +1,3 @@ -# HTTP Methods \ No newline at end of file +# HTTP Methods + +PHP allows for handling HTTP methods, which are a way of defining the action to be performed on the resource identified by a given URL. In PHP, the $_SERVER superglobal array can be used to identify the HTTP method of a specific request, typically a GET, POST, PUT, DELETE or HEAD. For example, to identify if a request is a POST request, you can use `if ($_SERVER['REQUEST_METHOD'] == 'POST') { // your code here }`. More advanced handling can be done by utilizing built-in PHP libraries or third-party packages. You may read more about it on the PHP documentation [here](https://www.php.net/manual/en/reserved.variables.server.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/ifelse@-McOv-ZPTGayX7Mx2Thw1.md b/src/data/roadmaps/php/content/ifelse@-McOv-ZPTGayX7Mx2Thw1.md index 7f3b5d0ae..6ee261d22 100644 --- a/src/data/roadmaps/php/content/ifelse@-McOv-ZPTGayX7Mx2Thw1.md +++ b/src/data/roadmaps/php/content/ifelse@-McOv-ZPTGayX7Mx2Thw1.md @@ -1 +1,14 @@ -# if/else \ No newline at end of file +# if/else + +In PHP, the if/else conditional statements are fundamental components that control the flow of the program based on specific conditions. When the 'if' condition is true, a block of code will execute. If that condition is not met (or false), the program proceeds to the 'else' statement (if provided), executing its block of code. This allows you to handle different situations dynamically. A simple example of this concept in action would be: + +```php +$number = 10; +if ($number > 5) { + echo "The number is greater than 5"; +} else { + echo "The number is not greater than 5"; +} +``` + +In this example, the output will be "The number is greater than 5" because the condition evaluated to true. You can find more information on the if/else conditional statements in the [PHP documentation](https://www.php.net/manual/en/control-structures.elseif.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/include@hKfv7V6bl2LXssq9Ffi7C.md b/src/data/roadmaps/php/content/include@hKfv7V6bl2LXssq9Ffi7C.md index 547bab924..a0e5888b3 100644 --- a/src/data/roadmaps/php/content/include@hKfv7V6bl2LXssq9Ffi7C.md +++ b/src/data/roadmaps/php/content/include@hKfv7V6bl2LXssq9Ffi7C.md @@ -1 +1,11 @@ -# include \ No newline at end of file +# include + +The 'include' statement in PHP is a useful method for inserting code written in one file into another. It's mainly used when the same code needs to be used in multiple files, avoiding redundancy and making code maintenance easier. If it cannot find the file, PHP will emit a warning but continue to execute the rest of the script. Here's a simple example: + +```php + +``` + +In this code snippet, 'filename.php' is the file containing the code that you want to insert. Just replace 'filename.php' with the actual file path you want to include. For the full details, check out the PHP documentation for 'include' [here](https://www.php.net/manual/en/function.include.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/include_once@SwtLDgyPmDry20qS4FBfH.md b/src/data/roadmaps/php/content/include_once@SwtLDgyPmDry20qS4FBfH.md index 033a27362..1a3ac797a 100644 --- a/src/data/roadmaps/php/content/include_once@SwtLDgyPmDry20qS4FBfH.md +++ b/src/data/roadmaps/php/content/include_once@SwtLDgyPmDry20qS4FBfH.md @@ -1 +1,11 @@ -# include_once \ No newline at end of file +# include_once + +The `include_once` statement is a part of PHP's file-handling toolkit, allowing developers to include a PHP file within another PHP file, but only for a one-time execution. This way, you can ensure that functions or objects defined in the included file are not duplicated leading to errors. It helps keep your code DRY (Don't Repeat Yourself) and clean. Here is a small example: + +```php +include_once 'database.php'; + +$db = new Database(); +``` + +In this simple code snippet, we include the `database.php` file once, giving us access to the `Database` class. You can find reference in the PHP Documentation [here](https://www.php.net/manual/en/function.include-once.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/indexed-arrays@j2S8dP3HlAOOoZdpj-7Dx.md b/src/data/roadmaps/php/content/indexed-arrays@j2S8dP3HlAOOoZdpj-7Dx.md index 688ca5db2..45936309f 100644 --- a/src/data/roadmaps/php/content/indexed-arrays@j2S8dP3HlAOOoZdpj-7Dx.md +++ b/src/data/roadmaps/php/content/indexed-arrays@j2S8dP3HlAOOoZdpj-7Dx.md @@ -1 +1,10 @@ -# Indexed Arrays \ No newline at end of file +# Indexed Arrays + +Indexed arrays in PHP store values that are accessed through numerical indexes, which start at 0 by default. This might be particularly useful when you have a list of items in a specific order. For example, you might use an indexed array to represent a list of your favorite books, where each book is numbered starting from 0. Each individual item in the array, book in this case, can be accessed by their specific index. You can use the array() function or the short array syntax [] to declare an indexed array. + +Example: +```php +$books = array("The Great Gatsby", "Moby Dick", "To Kill a Mockingbird"); +echo $books[0]; //Outputs "The Great Gatsby" +``` +You can find more on this in PHP's official documentation [here](https://www.php.net/manual/en/language.types.array.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/inheritance@c5q2e_jyMt8Pir5Od3lRi.md b/src/data/roadmaps/php/content/inheritance@c5q2e_jyMt8Pir5Od3lRi.md index a2e8e0baf..ec7b209cd 100644 --- a/src/data/roadmaps/php/content/inheritance@c5q2e_jyMt8Pir5Od3lRi.md +++ b/src/data/roadmaps/php/content/inheritance@c5q2e_jyMt8Pir5Od3lRi.md @@ -1 +1,23 @@ -# Inheritance \ No newline at end of file +# Inheritance + +Inheritance, a fundamental concept in object-oriented programming (OOP), is a feature that PHP supports. It lets us create classes which are extensions of other classes, inheriting their methods and properties. This concept allows the creation of more flexible and maintainable code, as it promotes code reuse. For instance, consider we have a 'Vehicle' class and we want to create a 'Car' class. Since cars are a type of vehicle, it would make sense for our 'Car' class to inherit from the 'Vehicle' class. + +```php +class Vehicle { + public $color; + function drive() { + echo "Driving..."; + } +} + +class Car extends Vehicle { + function horn() { + echo "Beeping..."; + } +} + +$myCar = new Car(); +$myCar->drive(); // Inherits drive method from Vehicle +$myCar->horn(); // Unique to Car +``` +In the above example, the 'Car' class inherits the drive method from the 'Vehicle' class but also has an additional method, horn. This is an illustration of how inheritance in PHP can help to organize your code efficiently and intuitively. Visit PHP's official documentation (https://www.php.net/manual/en/keyword.extends.php) for more details on inheritance. \ No newline at end of file diff --git a/src/data/roadmaps/php/content/input-validation@93oEIZttb85S23C1fLraP.md b/src/data/roadmaps/php/content/input-validation@93oEIZttb85S23C1fLraP.md index 984159757..fe7a56e22 100644 --- a/src/data/roadmaps/php/content/input-validation@93oEIZttb85S23C1fLraP.md +++ b/src/data/roadmaps/php/content/input-validation@93oEIZttb85S23C1fLraP.md @@ -1 +1,12 @@ -# Input Validation \ No newline at end of file +# Input Validation + +Input validation is a vital aspect of PHP security. It involves checking whether the user-provided data is in the expected format or not before it's processed further. This helps prevent potential security risks such as SQL injections, cross-site scripting (XSS) etc. Let's take an example of a simple form input validation: + +```php +if (filter_var($email, FILTER_VALIDATE_EMAIL)) { + echo("Email is valid"); +} else { + echo("Email is not valid"); +} +``` +This code uses PHP's built-in `filter_var()` function to ensure the data is a valid email address. If not, the form will not be submitted until valid data is entered. For more on PHP's built-in filters, visit [PHP Input Validation Documentation](https://www.php.net/manual/en/book.filter.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/installing-php@3_TuxOSzBuktBlBF05r_z.md b/src/data/roadmaps/php/content/installing-php@3_TuxOSzBuktBlBF05r_z.md index 802fd26d8..1a6e04907 100644 --- a/src/data/roadmaps/php/content/installing-php@3_TuxOSzBuktBlBF05r_z.md +++ b/src/data/roadmaps/php/content/installing-php@3_TuxOSzBuktBlBF05r_z.md @@ -1 +1,3 @@ -# Installing PHP \ No newline at end of file +# Installing PHP + +Installing PHP is an essential process to start developing PHP applications. PHP can be installed on Windows, macOS, and various distributions of Linux. Places to get PHP include the official PHP website, package managers like APT for Linux and Homebrew for macOS, or bundled solutions like XAMPP or WAMP that provide PHP along with a web server and database. After successful installation, you can run a simple PHP script to verify the installation. Here's an example, ``, which should display "Hello, World!" when accessed in a web browser. For detailed instructions, visit the official PHP installation guide at: https://www.php.net/manual/en/install.php. \ No newline at end of file diff --git a/src/data/roadmaps/php/content/interfaces@vu0H-TsD7hkJgOQbSRj92.md b/src/data/roadmaps/php/content/interfaces@vu0H-TsD7hkJgOQbSRj92.md index ae1d147ef..19371f302 100644 --- a/src/data/roadmaps/php/content/interfaces@vu0H-TsD7hkJgOQbSRj92.md +++ b/src/data/roadmaps/php/content/interfaces@vu0H-TsD7hkJgOQbSRj92.md @@ -1 +1,27 @@ -# Interfaces \ No newline at end of file +# Interfaces + +Interfaces in PHP serve as a blueprint for designing classes. They ensure that a class adheres to a certain contract, all without defining how those methods should function. As PHP is not a strictly typed language, interfaces can be particularly useful in large codebases to maintain continuity and predictability. For example, in PHP, an interface 'iTemplate' could be defined with methods 'setVariable' and 'getHtml'. Any class that implements this interface must define these methods. Here is a snippet: + +```php +interface iTemplate { + public function setVariable($name, $var); + public function getHtml($template); +} + +class Template implements iTemplate { + private $vars = array(); + + public function setVariable($name, $var) { + $this->vars[$name] = $var; + } + + public function getHtml($template) { + foreach($this->vars as $name => $value) { + $template = str_replace('{' . $name . '}', $value, $template); + } + return $template; + } +} +``` + +To learn more about interfaces in PHP, please refer to the official [PHP Documentation](https://www.php.net/manual/en/language.oop5.interfaces.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/introduction-to-php@_hYN0gEi9BL24nptEtXWU.md b/src/data/roadmaps/php/content/introduction-to-php@_hYN0gEi9BL24nptEtXWU.md index fa2e3765c..e901b6799 100644 --- a/src/data/roadmaps/php/content/introduction-to-php@_hYN0gEi9BL24nptEtXWU.md +++ b/src/data/roadmaps/php/content/introduction-to-php@_hYN0gEi9BL24nptEtXWU.md @@ -1 +1,9 @@ -# Introduction to PHP \ No newline at end of file +# Introduction to PHP + +PHP, also known as Hypertext Preprocessor, is a powerful scripting language used predominantly for creating dynamic web pages and applications. It provides seamless interaction with databases, easier control of content, session tracking, and cookies. Being an open-source language, it's favored by developers for its flexibility, speed, and security. A simple PHP code to print text would be +```php + +``` +Here the "echo" command in PHP helps to output one or more strings. You can find more about PHP in the [official PHP documentation](https://www.php.net/docs.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/json-processing@DB2cxZE58WCCavW2PNwmf.md b/src/data/roadmaps/php/content/json-processing@DB2cxZE58WCCavW2PNwmf.md index 9df3a7a96..fa93d2fcf 100644 --- a/src/data/roadmaps/php/content/json-processing@DB2cxZE58WCCavW2PNwmf.md +++ b/src/data/roadmaps/php/content/json-processing@DB2cxZE58WCCavW2PNwmf.md @@ -1 +1,21 @@ -# JSON Processing \ No newline at end of file +# JSON Processing + +JSON Processing in PHP refers to the handling, reading, and manipulation of JSON formatted data. JSON, or JavaScript Object Notation, is a versatile data format used worldwide due to its easy readability and robustness. PHP natively supports JSON and includes built-in functions like `json_encode()` and `json_decode()`. The `json_encode()` function returns a JSON representation of a value, particularly useful when you need to pass arrays or objects to a script. On the other hand, `json_decode()` is used to extract data from a JSON file or a JSON-encoded string, converting it into a PHP variable. Here's a quick example: + +```php +// Create an array +$data = array('a' => 1, 'b' => 2, 'c' => 3); + +// Encode the array into a JSON string +$json = json_encode($data); +echo $json; + +// Output: {"a":1,"b":2,"c":3} + +// Decode the JSON string back into an array +$decoded = json_decode($json, true); +print_r($decoded); + +// Output: Array ( [a] => 1 [b] => 2 [c] => 3 ) +``` +To master JSON processing in PHP, refer to the official documentation: [PHP JSON Manual](https://www.php.net/manual/en/book.json.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/lamp@7LjxtrmgJtTJc0_kP83Tr.md b/src/data/roadmaps/php/content/lamp@7LjxtrmgJtTJc0_kP83Tr.md index 63164489a..fc391caaf 100644 --- a/src/data/roadmaps/php/content/lamp@7LjxtrmgJtTJc0_kP83Tr.md +++ b/src/data/roadmaps/php/content/lamp@7LjxtrmgJtTJc0_kP83Tr.md @@ -1 +1,3 @@ -# LAMP \ No newline at end of file +# LAMP + +LAMP refers to the combined use of Linux OS, Apache HTTP Server, MySQL relational database management system, and PHP; it's a popular stack for creating and hosting websites. For PHP, LAMP is a robust, open-source web development platform that supports a wide range of dynamic websites and applications. Suppose you plan to develop a content management system (CMS), forums, or e-commerce shops. In that case, PHP, as a part of the LAMP stack, helps provide a flexible development environment. Here, PHP works hand-in-hand with MySQL to access and manage databases, get queried results, and embed them into HTML pages by the Apache HTTP Server before sending them to the client side.[Official PHP Documentation](https://www.php.net/manual/en/introduction.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/laravel@zsscRQZIq5o0JZir9hlz-.md b/src/data/roadmaps/php/content/laravel@zsscRQZIq5o0JZir9hlz-.md index b2932626a..00c6680c2 100644 --- a/src/data/roadmaps/php/content/laravel@zsscRQZIq5o0JZir9hlz-.md +++ b/src/data/roadmaps/php/content/laravel@zsscRQZIq5o0JZir9hlz-.md @@ -1 +1,3 @@ -# Laravel \ No newline at end of file +# Laravel + +Laravel is a robust, elegant PHP framework perfect for web application development, providing developers with a lot of features that boost productivity. Laravel leverages the power of PHP for handling complex tasks such as routing, sessions, caching, and authentication, making it much simpler and quicker for PHP developers to build applications. Laravel's MVC architecture promotes clean, DRY code and separates business logic from UI which significantly improves scalability as well as ease of maintenance. A sample code for a basic Laravel route could be: `Route::get('/', function () { return view('welcome'); });`. For more insights on Laravel, you can check out the official Laravel documentation [here](https://laravel.com/docs). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/loops@qwt8xN4vuTrY-D0czYITI.md b/src/data/roadmaps/php/content/loops@qwt8xN4vuTrY-D0czYITI.md index d31a16aa6..569049026 100644 --- a/src/data/roadmaps/php/content/loops@qwt8xN4vuTrY-D0czYITI.md +++ b/src/data/roadmaps/php/content/loops@qwt8xN4vuTrY-D0czYITI.md @@ -1 +1,13 @@ -# Loops \ No newline at end of file +# Loops + +PHP incorporates the use of loops, which are a vital part of programming. They allow a block of code to be executed repeatedly based on a certain condition or until a specific condition is met. In PHP, there are four types of loops - 'while', 'do-while', 'for' and 'foreach'. The 'while' loop continues executing its nested code as long as the condition remains true. The 'do-while' loop executes a block of code at least once, and then either continues executing it or stops, based on the condition. The 'for' loop is often used when the number of iterations is known. The 'foreach' loop works with arrays and is used to loop through each key/value pair in an array. Here's a simple example of a 'for' loop in PHP: + +```php + +``` + +In this example, the loop will execute five times, with $i increasing by one each time, outputting the numbers from 0 to 4. You can find more detailed explanation and examples of loops in PHP in the official PHP documentation [here](https://www.php.net/manual/en/language.control-structures.php). diff --git a/src/data/roadmaps/php/content/magic-methods@rSXsPWto7Jeyw3Szl9pvf.md b/src/data/roadmaps/php/content/magic-methods@rSXsPWto7Jeyw3Szl9pvf.md index 36b261b9e..a85145a71 100644 --- a/src/data/roadmaps/php/content/magic-methods@rSXsPWto7Jeyw3Szl9pvf.md +++ b/src/data/roadmaps/php/content/magic-methods@rSXsPWto7Jeyw3Szl9pvf.md @@ -1 +1,16 @@ -# Magic methods \ No newline at end of file +# Magic methods + +PHP Magic Methods, often considered the hooks of the language, provide developers a way to change how objects will respond to particular language constructs. Magic methods are special functions that start with "__" such as __construct(), __destruct(), __call(), __get(), __set() and more. They enable us to perform certain tasks automatically when specific actions occur. For example, __construct() executes when an object is created while __destruct() triggers when an object is no longer needed. Let's see the __construct magic method in action: + +```php +class Car { + public $color; + public function __construct($color) { + $this->color = $color; + } +} +$blueCar = new Car("Blue"); // This will call the __construct() method. +echo $blueCar->color; // Outputs "Blue". +``` + +To delve deeper into magic methods and their various usages, you can check the official PHP documentation. Here's the link: [PHP Magic Methods](https://www.php.net/manual/en/language.oop5.magic.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/mamp@t7p7TU2khaxsZPYAdwFAA.md b/src/data/roadmaps/php/content/mamp@t7p7TU2khaxsZPYAdwFAA.md index 5bc72b480..ec04302d1 100644 --- a/src/data/roadmaps/php/content/mamp@t7p7TU2khaxsZPYAdwFAA.md +++ b/src/data/roadmaps/php/content/mamp@t7p7TU2khaxsZPYAdwFAA.md @@ -1 +1,3 @@ -# MAMP \ No newline at end of file +# MAMP + +MAMP stands for Macintosh, Apache, MySQL, and PHP. It is a popular software stack that enables developers to run a local server environment. While other technology stacks might be more relevant to different languages or platform-specific development, MAMP is highly beneficial for PHP development. MAMP allows PHP developers to run their code in a localhost environment on their systems, making testing and debugging more straightforward. MAMP bundles all the required software packages (Apache, MySQL, PHP) into one convenient installation, supporting developers in creating a reliable, consistent development environment without tussle. However, as an assistant, I cannot provide a code sample for this topic since it's not directly related to coding in PHP. Here's a link to the MAMP resource where you can find more details: [MAMP Official Site](https://www.mamp.info/en/). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/match@3gNzX-bw2iqur7U7-_W38.md b/src/data/roadmaps/php/content/match@3gNzX-bw2iqur7U7-_W38.md index 15b92de8c..c7a0b408e 100644 --- a/src/data/roadmaps/php/content/match@3gNzX-bw2iqur7U7-_W38.md +++ b/src/data/roadmaps/php/content/match@3gNzX-bw2iqur7U7-_W38.md @@ -1 +1,12 @@ -# match \ No newline at end of file +# match + +Match expressions are an integral feature of PHP, introduced in PHP 8.0 as an alternative to the switch statement. Compared to the switch statement, match expressions are safer since they don't require break statements and are more concise. The match expression can be an excellent tool for pattern matching. Here's an example: + +```php +$message = match ($statusCode) { + 200, 300 => 'OK', + 400 => 'error', + default => 'unknown status code', +}; +``` +In this code, based on the value of `$statusCode`, the `match` expression assigns a specific text to the `$message`. If `$statusCode` is not 200, 300, or 400, the `default` case applies. After running the code, the `$message` variable contains the result of the `match` expression. You can learn more about `match` expressions in PHP documentation: https://www.php.net/manual/en/control-structures.match.php. \ No newline at end of file diff --git a/src/data/roadmaps/php/content/memory-management@bt7dK2PcOZ72B9HXPyMwL.md b/src/data/roadmaps/php/content/memory-management@bt7dK2PcOZ72B9HXPyMwL.md index 0f0ebe5f9..85f86a3d0 100644 --- a/src/data/roadmaps/php/content/memory-management@bt7dK2PcOZ72B9HXPyMwL.md +++ b/src/data/roadmaps/php/content/memory-management@bt7dK2PcOZ72B9HXPyMwL.md @@ -1 +1,11 @@ -# Memory Management \ No newline at end of file +# Memory Management + +Memory Management is a crucial part of PHP performance optimization. Efficient memory use can significantly boost the speed and reliability of your PHP applications. PHP automatically provides a garbage collector which cleans up unused memory, but understanding and managing your script's memory usage can result in better use of resources. For instance, `unset()` function can help in freeing up memory by destroying the variables that are no longer used. Here is an example: + +```PHP +$string = "This is a long string that's going to use a lot of memory!"; +echo memory_get_usage(); // Outputs: 36640 +unset($string); +echo memory_get_usage(); // Outputs: 36640 +``` +In this code snippet, you'll notice that the memory used remains the same even when the `$string` variable is unset. This is because `unset() ` only reduces the reference count of the variable in PHP's memory manager, and the memory will be cleared at the end of script execution. Avoiding unnecessary data storage and using inherent PHP functions, can help optimize memory management. You can learn more about memory management from the [PHP Manual](https://www.php.net/manual/en/features.gc.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/multi-dimensional-arrays@uARTOZ-ZwugSmbCJoRS5Y.md b/src/data/roadmaps/php/content/multi-dimensional-arrays@uARTOZ-ZwugSmbCJoRS5Y.md index eceb13baf..f0fb8836d 100644 --- a/src/data/roadmaps/php/content/multi-dimensional-arrays@uARTOZ-ZwugSmbCJoRS5Y.md +++ b/src/data/roadmaps/php/content/multi-dimensional-arrays@uARTOZ-ZwugSmbCJoRS5Y.md @@ -1 +1,11 @@ -# Multi-dimensional Arrays \ No newline at end of file +# Multi-dimensional Arrays + +Multi-dimensional arrays in PHP are a type of array that contains one or more arrays. Essentially, it's an array of arrays. This allows you to store data in a structured manner, much like a table or a matrix. The fundamental idea is that each array value can, in turn, be another array. For instance, you can store information about various users, where each user (a primary array element) contains several details about them (in a secondary array like email, username etc.). Here's an example: +``` +$users = array( + array("John", "john@example.com", "john123"), + array("Jane", "jane@example.com", "jane123"), + array("Doe", "doe@example.com", "doe123") +); +``` +You can access elements of this array just like you would with a normal array but with an extra index denoting the 'depth'. More about this can be found in the [PHP documentation](https://www.php.net/manual/en/language.types.array.php). diff --git a/src/data/roadmaps/php/content/mysqli@YLuo0oZJzTCoiZoOSG57z.md b/src/data/roadmaps/php/content/mysqli@YLuo0oZJzTCoiZoOSG57z.md index 6fffd3bba..c9cda76f6 100644 --- a/src/data/roadmaps/php/content/mysqli@YLuo0oZJzTCoiZoOSG57z.md +++ b/src/data/roadmaps/php/content/mysqli@YLuo0oZJzTCoiZoOSG57z.md @@ -1 +1,20 @@ -# MySQLi \ No newline at end of file +# MySQLi + +MySQLi is a PHP extension that allows PHP programs to connect with MySQL databases. This extension provides the capability to perform queries, retrieve data, and perform complex operations on MySQL databases using PHP. MySQLi comes with an object-oriented and procedural interface and supports prepared statements, multiple statements, and transactions. Here's a basic example of using MySQLi to connect to a MySQL database: + +```php +$servername = "localhost"; +$username = "username"; +$password = "password"; +$dbname = "myDB"; + +// Create connection +$conn = new mysqli($servername, $username, $password, $dbname); + +// Check connection +if ($conn->connect_error) { + die("Connection failed: " . $conn->connect_error); +} +echo "Connected successfully"; +``` +You can get more information about MySQLi from PHP documentation [here](https://www.php.net/manual/en/book.mysqli.php). diff --git a/src/data/roadmaps/php/content/named-arguments@RkNjYva8o_jXp9suz5YdG.md b/src/data/roadmaps/php/content/named-arguments@RkNjYva8o_jXp9suz5YdG.md index a89a98cb1..0fa07db05 100644 --- a/src/data/roadmaps/php/content/named-arguments@RkNjYva8o_jXp9suz5YdG.md +++ b/src/data/roadmaps/php/content/named-arguments@RkNjYva8o_jXp9suz5YdG.md @@ -1 +1,10 @@ -# Named Arguments \ No newline at end of file +# Named Arguments + +Named arguments in PHP, introduced with PHP 8.0, allow you to specify the values of required parameters by their names, instead of their position in the function call, thus making your code more readable, reducing mistakes, and allowing for unimportant arguments to be skipped. Here's an array_fill() function using named arguments: + +```php +) allows null values to be returned safely, making your code more robust. Here's a quick example, consider $session?->user?->name. If $session or user is null, PHP will stop further execution and simply return null. This makes PHP more resilient when processing unpredictable data. More information can be found on the [PHP documentation webpage](https://www.php.net/manual/en/language.oop5.nullsafe.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/object-relational-mapping-orm@SeqGIfcLuveZ2z5ZSXcOd.md b/src/data/roadmaps/php/content/object-relational-mapping-orm@SeqGIfcLuveZ2z5ZSXcOd.md index 10fd2b6c0..8ef7d1b3e 100644 --- a/src/data/roadmaps/php/content/object-relational-mapping-orm@SeqGIfcLuveZ2z5ZSXcOd.md +++ b/src/data/roadmaps/php/content/object-relational-mapping-orm@SeqGIfcLuveZ2z5ZSXcOd.md @@ -1 +1,12 @@ -# Object-Relational Mapping (ORM) \ No newline at end of file +# Object-Relational Mapping (ORM) + +Object-Relational Mapping (ORM) is a popular technique used with PHP to convert data between incompatible type systems using an object-oriented programming language. Essentially, it saves PHP developers time by enabling them to work with databases using OOP standards and avoid writing long SQL queries. One commonly used ORM in PHP is Doctrine. For instance, to save data into a products table, you don't use SQL but OOP-style code: + +```php +$product = new Product(); +$product->setName('New Product'); +$entityManager->persist($product); +$entityManager->flush(); +``` + +You can see a more detailed explanation about it at the PHP documentation on [Object Relational Mapping (ORM)](https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/tutorials/getting-started.html). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/oop-fundamentals@yTviiPFR5b_dr3WyxdxxQ.md b/src/data/roadmaps/php/content/oop-fundamentals@yTviiPFR5b_dr3WyxdxxQ.md index 2b7006b2f..ac0f4b42b 100644 --- a/src/data/roadmaps/php/content/oop-fundamentals@yTviiPFR5b_dr3WyxdxxQ.md +++ b/src/data/roadmaps/php/content/oop-fundamentals@yTviiPFR5b_dr3WyxdxxQ.md @@ -1 +1,17 @@ -# OOP Fundamentals \ No newline at end of file +# OOP Fundamentals + +In PHP, Object-Oriented Programming (OOP) Fundamentals cover critical aspects like classes, objects, properties, and methods. OOP facilitates efficient code reusability and makes it easier to manage and modify code. For example, here's a code snippet that represents a class with a method and a property in PHP: + +```php +class Hello { + public $greeting = "Hello, world!"; + + public function displayGreeting() { + echo $this->greeting; + } +} +$hello = new Hello(); +$hello->displayGreeting(); // Outputs "Hello, world!" +``` + +This snippet defines a class `Hello` with a property `$greeting` and a method `displayGreeting()`. Instances of this class can access these methods and properties. OOP Fundamentals in PHP are much more comprehensive, encompassing concepts like inheritance, encapsulation, and polymorphism. To dive deeper, explore the [official PHP Documentation](https://php.net/manual/en/language.oop5.basic.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/opcode-caching@NieqZd1juaNYoZOrB7e31.md b/src/data/roadmaps/php/content/opcode-caching@NieqZd1juaNYoZOrB7e31.md index 35b415c7f..cd4a8f36b 100644 --- a/src/data/roadmaps/php/content/opcode-caching@NieqZd1juaNYoZOrB7e31.md +++ b/src/data/roadmaps/php/content/opcode-caching@NieqZd1juaNYoZOrB7e31.md @@ -1 +1,10 @@ -# Opcode Caching \ No newline at end of file +# Opcode Caching + +Opcode caching is a technique that can significantly enhance the PHP performance. It works by storing precompiled script bytecode in memory, thus eliminating the need for PHP to load and parse scripts on each request. For opcode caching, OPCache extension is often used in PHP. With this, the PHP script's compiled version is stored for subsequent requests, reducing the overhead of code parsing and compiling. As a result, your applications experience faster execution and lower CPU usage. An Example of a way to enable OPCache in your php.ini configuration file might look like, +``` + opcache.enable=1 + opcache.memory_consumption=128 + opcache.max_accelerated_files=4000 + opcache.revalidate_freq=60 +``` +Do check out the [PHP documentation](https://www.php.net/manual/en/book.opcache.php) for a detailed guide on using OPCache for opcode caching. \ No newline at end of file diff --git a/src/data/roadmaps/php/content/packagist@xZf2jjnCVHwYfDH2hs9kR.md b/src/data/roadmaps/php/content/packagist@xZf2jjnCVHwYfDH2hs9kR.md index 46fb195d1..60d359192 100644 --- a/src/data/roadmaps/php/content/packagist@xZf2jjnCVHwYfDH2hs9kR.md +++ b/src/data/roadmaps/php/content/packagist@xZf2jjnCVHwYfDH2hs9kR.md @@ -1 +1,3 @@ -# Packagist \ No newline at end of file +# Packagist + +Packagist is the primary package repository for PHP, providing a service for hosting and distributing PHP package dependencies. Developers can use it to upload their PHP packages and share them with other developers globally. In conjunction with Composer, Packagist helps manage package versions and resolve dependencies for PHP, acting as a crucial part of modern PHP development. For example, to install a package from Packagist, you would run the command `composer require vendor/package`. You can find more information and documentation on the official [Packagist website](https://packagist.org/). diff --git a/src/data/roadmaps/php/content/parameters--return-values@mpQKoBzsOa-5iWo08sOhQ.md b/src/data/roadmaps/php/content/parameters--return-values@mpQKoBzsOa-5iWo08sOhQ.md index 711f6624a..fd61bb9bc 100644 --- a/src/data/roadmaps/php/content/parameters--return-values@mpQKoBzsOa-5iWo08sOhQ.md +++ b/src/data/roadmaps/php/content/parameters--return-values@mpQKoBzsOa-5iWo08sOhQ.md @@ -1 +1,13 @@ -# Parameters / Return Values \ No newline at end of file +# Parameters / Return Values + +Parameters in PHP functions specify the input that the function expects to receive when it is called. They can be of various types like strings, integers, arrays, or even objects. PHP also supports default values for parameters and passing by reference. In PHP, the 'return' statement is often used to end the execution of a function and send back a value. Return values can be any data type. Here's a simple example: + +```php +function addNumbers($num1, $num2) { + $sum = $num1 + $num2; + return $sum; +} + +echo addNumbers(3, 4); // Outputs: 7 +``` +In the above code, `$num1` and `$num2` are parameters, and the sum of these numbers is the return value. To deepen your understanding, visit PHP function parameters and return values guide on the [official PHP website](https://www.php.net/manual/en/functions.arguments.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/password-hashing@JbWFfJiCRrXDhnuIx_lqx.md b/src/data/roadmaps/php/content/password-hashing@JbWFfJiCRrXDhnuIx_lqx.md index 687bf221b..2e421c679 100644 --- a/src/data/roadmaps/php/content/password-hashing@JbWFfJiCRrXDhnuIx_lqx.md +++ b/src/data/roadmaps/php/content/password-hashing@JbWFfJiCRrXDhnuIx_lqx.md @@ -1 +1,16 @@ -# Password Hashing \ No newline at end of file +# Password Hashing + +Password Hashing in PHP is a crucial aspect of security, which involves converting a plaintext password into a unique hash that cannot be easily reversed. PHP's built-in functions - `password_hash()` and `password_verify()` - are usually employed for this purpose. `password_hash()` creates a new password hash using a strong one-way hashing algorithm, while `password_verify()` checks if the given hash matches the password provided. This makes it extremely difficult for malicious actors to get the original password, even if they have the hash. + +```php +// Hashing the password +$hash = password_hash('mypassword', PASSWORD_DEFAULT); + +// Verifying the password +if (password_verify('mypassword', $hash)) { + echo 'Password is valid!'; +} else { + echo 'Invalid password.'; +} +``` +Use PHP's built-in functions for password hashing to enhance your application's security. For more information, you can refer to [PHP documentation here](https://www.php.net/manual/en/function.password-hash.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/pdo@cJtPz1RMN1qDE4eRdv4N_.md b/src/data/roadmaps/php/content/pdo@cJtPz1RMN1qDE4eRdv4N_.md index 34f84f238..3b4aaf26f 100644 --- a/src/data/roadmaps/php/content/pdo@cJtPz1RMN1qDE4eRdv4N_.md +++ b/src/data/roadmaps/php/content/pdo@cJtPz1RMN1qDE4eRdv4N_.md @@ -1 +1,16 @@ -# PDO \ No newline at end of file +# PDO + +PDO (PHP Data Objects) is an interface in PHP that provides a lightweight, consistent way for working with databases in PHP. PDO allows you to use any database without changing your PHP code, making your code database-independent. Furthermore, it offers robust error handling and can utilize prepared statements to prevent SQL injection attacks. Here is how you could connect and fetch data from a MySQL database using PDO: + +```php +try { + $pdo = new PDO('mysql:host=localhost;dbname=test', 'username', 'password'); + $stmt = $pdo->query('SELECT * FROM myTable'); + while ($row = $stmt->fetch()) { + echo $row['name'] . "\n"; + } +} catch (PDOException $e) { + echo "Connection failed: " . $e->getMessage(); +} +``` +You can learn more about PDO at the official PHP documentation site: [PHP: PDO - Manual](https://www.php.net/manual/en/book.pdo.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/performance-optimization@M1nVsh_sCSFJRf6-7Ttsj.md b/src/data/roadmaps/php/content/performance-optimization@M1nVsh_sCSFJRf6-7Ttsj.md index 0e1a81bff..a35a1c1e7 100644 --- a/src/data/roadmaps/php/content/performance-optimization@M1nVsh_sCSFJRf6-7Ttsj.md +++ b/src/data/roadmaps/php/content/performance-optimization@M1nVsh_sCSFJRf6-7Ttsj.md @@ -1 +1,21 @@ -# Performance Optimization \ No newline at end of file +# Performance Optimization + +Performance Optimization linked with Advanced Database Techniques in PHP ensures your database-driven applications run efficiently. This involves techniques like indexing, using EXPLAIN SQL command, de-normalization, and caching query results. For instance, an effective technique is caching query results, which can significantly reduce the number of database calls. PHP offers functions to serialize and unserialize data, you can store your result set in a serialized form and when needed, retrieve it quickly, unserialize it and voila, you have your data ready with no database calls. Here's a simple example of caching MySQL query with PHP: + +``` +$query = "SELECT * FROM my_table"; +$cache_file = '/tmp/cache/' . md5($query); + +if (file_exists($cache_file)) { + $result_set = unserialize(file_get_contents($cache_file)); +} else { + $result= mysql_query($query); + $result_set= array(); + while ($row = mysql_fetch_array($result)) { + $result_set[]= $row; + } + file_put_contents($cache_file, serialize($result_set)); +} +``` + +For more information, refer to the official [PHP documentation](https://www.php.net/manual/en/book.mysql.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/pest@d6MydchA52HIxfAUjmZui.md b/src/data/roadmaps/php/content/pest@d6MydchA52HIxfAUjmZui.md index 8e1bb56a6..dcfb9e406 100644 --- a/src/data/roadmaps/php/content/pest@d6MydchA52HIxfAUjmZui.md +++ b/src/data/roadmaps/php/content/pest@d6MydchA52HIxfAUjmZui.md @@ -1 +1,11 @@ -# Pest \ No newline at end of file +# Pest + +Pest is an innovative and elegant testing framework for PHP. Think of it as a stylish and streamlined alternative to PHPUnit. Pest makes testing your PHP code a breeze by enabling expressive and flexible test cases. It provides higher-level abstractions to minimize boilerplate code without disrupting the ability to integrate traditional PHPUnit tests. For example, using Pest can make a test case as simple as writing a closure: + +```php +it('has homepage', function () { + $response = get('/'); + $response->assertStatus(200); +}); +``` +It simplifies your testing workflow and makes it more readable and impactful. Check out the official Pest documentation at https://pestphp.com/. diff --git a/src/data/roadmaps/php/content/phan@B45YVzov8X_iOtneiFEqa.md b/src/data/roadmaps/php/content/phan@B45YVzov8X_iOtneiFEqa.md index c63bc36ad..d93288c8e 100644 --- a/src/data/roadmaps/php/content/phan@B45YVzov8X_iOtneiFEqa.md +++ b/src/data/roadmaps/php/content/phan@B45YVzov8X_iOtneiFEqa.md @@ -1 +1,17 @@ -# Phan \ No newline at end of file +# Phan + +Phan is a static analysis tool specially made for PHP language, greatly useful in catching common issues in the code before execution. It can analyze the syntax and behaviors in PHP code, detecting problems such as undeclared variables, type inconsistencies, uncaught exceptions, and more. Interestingly, Phan has a particular strength — it understands the relationships among PHP's different features, making the tool effective in finding subtle, complicated bugs. To use it, simply install it using composer and run the command 'phan' in your project directory. Want to learn more? The official PHP documentation can support you: [PHP Documentation](https://www.php.net/manual/en/). +```php +assertEquals(0, count($stack)); + + array_push($stack, 'foo'); + $this->assertEquals('foo', $stack[count($stack)-1]); + $this->assertEquals(1, count($stack)); + + $this->assertEquals('foo', array_pop($stack)); + $this->assertEquals(0, count($stack)); + } +} +?> +``` +In this example, we’re testing the 'push' and 'pop' functionality of an array. Want to go deeper into PHPUnit? Check out the [PHP documentation](https://phpunit.de/getting-started/phpunit-7.html). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/polymorphism@gtq5KrghF28f5G8nuDcYQ.md b/src/data/roadmaps/php/content/polymorphism@gtq5KrghF28f5G8nuDcYQ.md index ee8632b70..221337220 100644 --- a/src/data/roadmaps/php/content/polymorphism@gtq5KrghF28f5G8nuDcYQ.md +++ b/src/data/roadmaps/php/content/polymorphism@gtq5KrghF28f5G8nuDcYQ.md @@ -1 +1,33 @@ -# Polymorphism \ No newline at end of file +# Polymorphism + +Polymorphism is a core concept in object-oriented programming that PHP supports. It provides a mechanism to use one interface for different underlying forms, enabling different objects to process differently based on their data type. In PHP, polymorphism can be achieved through inheritance and interfaces. For example, you may have a parent class 'Shape' and child classes 'Circle', 'Rectangle', etc. They all can have a method 'draw' but with different implementations. It's not limited to classes; you can also use polymorphism with interfaces by implementing different classes with the same interface where each class will have different code for the same method. + +Here's a small sample code demonstrating the concept: +```php +draw(); +} + +drawShape(new Circle()); +drawShape(new Rectangle()); +?> +``` + +This creates a scalable way to add more shapes, as you only need to follow the 'Shape' interface. For more details, you can read the PHP documentation on polymorphism [here](https://www.php.net/manual/en/language.oop5.polymorphism.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/print@NQUmO90sqe7fnzod3Ia8H.md b/src/data/roadmaps/php/content/print@NQUmO90sqe7fnzod3Ia8H.md index 238c5d796..dced2f393 100644 --- a/src/data/roadmaps/php/content/print@NQUmO90sqe7fnzod3Ia8H.md +++ b/src/data/roadmaps/php/content/print@NQUmO90sqe7fnzod3Ia8H.md @@ -1 +1,3 @@ -# print \ No newline at end of file +# print + +The 'print' statement in PHP is an in-built function used for outputting one or more strings. Unlike 'echo', it is not a language construct and has a return value. However, it is slower because it uses expressions. The text or numeric data that 'print' outputs can be shown directly or stored in a variable. For instance, to print a string you may use `print("Hello, World!");`, and for using it with a variable, `echo $variable;` is suitable. For more nuances and subtleties of using 'print', refer to the PHP official documentation: [PHP print](https://www.php.net/manual/en/function.print.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/print_r@wsC7OGXOyfCY4pLLNrR2v.md b/src/data/roadmaps/php/content/print_r@wsC7OGXOyfCY4pLLNrR2v.md index a1a623895..34b65cb36 100644 --- a/src/data/roadmaps/php/content/print_r@wsC7OGXOyfCY4pLLNrR2v.md +++ b/src/data/roadmaps/php/content/print_r@wsC7OGXOyfCY4pLLNrR2v.md @@ -1 +1,3 @@ -# print_r \ No newline at end of file +# print_r + +The print_r function in PHP is used to print human-readable information about a variable, ranging from simple values to more complex, multi-dimensional arrays and objects. It's exceptionally helpful while debugging, providing more information about the variable's contents than the echo or print functions. For example, in the code `$array = array('apple', 'banana', 'cherry'); print_r($array);`, it will display Array ( [0] => apple [1] => banana [2] => cherry ). Further information about the print_r function can be found at the [PHP documentation](https://www.php.net/manual/en/function.print-r.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/process-control@NTKUMgsKGYISIyhgOJPQn.md b/src/data/roadmaps/php/content/process-control@NTKUMgsKGYISIyhgOJPQn.md index 425bb1950..f869b00aa 100644 --- a/src/data/roadmaps/php/content/process-control@NTKUMgsKGYISIyhgOJPQn.md +++ b/src/data/roadmaps/php/content/process-control@NTKUMgsKGYISIyhgOJPQn.md @@ -1 +1,19 @@ -# Process Control \ No newline at end of file +# Process Control + +Process Control, a crucial aspect of PHP system interactions, pertains to the ability to manage child processes within larger PHP scripts. Through the Process Control Extensions, PHP can create, monitor and control these child processes efficiently. These functions help develop robust client-server systems by managing and bringing multi-threading capabilities to single-threaded PHP scripts. For instance, when creating a new child process using pcntl_fork() function, the return value in the parent process is the PID of the newly created child process whereas, in the child process, '0' is returned. Remember, this feature isn't enabled by default in PHP. + +Here's a short PHP code demonstrating Process Control: +```php + +``` +More examples and commands can be found in PHP's official documentation: [Process Control Functions](https://www.php.net/manual/en/ref.pcntl.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/profiling-techniques@_Dh78x_tPLqZweg--qZFQ.md b/src/data/roadmaps/php/content/profiling-techniques@_Dh78x_tPLqZweg--qZFQ.md index a980b3a8b..417ae33a5 100644 --- a/src/data/roadmaps/php/content/profiling-techniques@_Dh78x_tPLqZweg--qZFQ.md +++ b/src/data/roadmaps/php/content/profiling-techniques@_Dh78x_tPLqZweg--qZFQ.md @@ -1 +1,11 @@ -# Profiling Techniques \ No newline at end of file +# Profiling Techniques + +Profiling is an analytical process within PHP that focuses on optimizing the application’s performance. It involves pinpointing bottlenecks and problematic sections of your PHP code that cause poor performance, often using profiling tools. One such tool is Xdebug, which provides detailed information about how each line of code is executed. This process helps in understanding how long an operation takes to execute, which parts consume more memory, and which functions/methods are most frequently used, thereby enabling an optimization strategy. Here's a snippet of how to use Xdebug: + +```php +xdebug_start_trace(); +// Your code here +xdebug_stop_trace(); +``` + +For more details, refer to the Xdebug documentation on the [PHP website](https://xdebug.org/docs/profiler). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/properties-and-methods@MRAPXshy9RoYdReY6grf_.md b/src/data/roadmaps/php/content/properties-and-methods@MRAPXshy9RoYdReY6grf_.md index 0f320fcb9..d5536e25b 100644 --- a/src/data/roadmaps/php/content/properties-and-methods@MRAPXshy9RoYdReY6grf_.md +++ b/src/data/roadmaps/php/content/properties-and-methods@MRAPXshy9RoYdReY6grf_.md @@ -1 +1,15 @@ -# Properties and Methods \ No newline at end of file +# Properties and Methods + +Properties and Methods are fundamental components of Object-Oriented Programming (OOP) in PHP. Properties are just like variables; they hold information that an object will need to use. Methods, on the other hand, are similar to functions; they perform an action on an object's properties. In PHP, properties are declared using visibility keywords (public, protected, or private) followed by a regular variable declaration, while methods are declared like functions but inside a class. Here is a simple example: + +``` +class Car { + public $color; // Property + + // Method + public function setColor($color) { + $this->color = $color; + } +} +``` +In this example, `$color` is a property and `setColor()` is a method. Learn more through [PHP documentation](https://www.php.net/manual/en/language.oop5.properties.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/psalm@T1XD93j6Lkpl88JSmys9b.md b/src/data/roadmaps/php/content/psalm@T1XD93j6Lkpl88JSmys9b.md index 571264f3a..be177b5a7 100644 --- a/src/data/roadmaps/php/content/psalm@T1XD93j6Lkpl88JSmys9b.md +++ b/src/data/roadmaps/php/content/psalm@T1XD93j6Lkpl88JSmys9b.md @@ -1 +1,8 @@ -# Psalm \ No newline at end of file +# Psalm + +Psalm is a popular static analysis tool tailored for PHP. It identifies potential issues in your code, including syntax errors, unused variables, and type mismatches, before you run the code. This helps to improve code quality and maintainability. It's quite powerful, it can even understand complex scenarios using its template/interface system. To analyze your PHP code with Psalm, you simply need to install it and then run it against your PHP file or directory. Here's an example of how you might run Psalm against a file called 'example.php': + +```bash +vendor/bin/psalm example.php +``` +For more information on using Psalm with PHP, you can check out the official PHP documentation [here](https://psalm.dev/docs/). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/psr-standards@3tONibbRgK7HCwGTE2Gqw.md b/src/data/roadmaps/php/content/psr-standards@3tONibbRgK7HCwGTE2Gqw.md index 6d3b9e0dc..3e8599661 100644 --- a/src/data/roadmaps/php/content/psr-standards@3tONibbRgK7HCwGTE2Gqw.md +++ b/src/data/roadmaps/php/content/psr-standards@3tONibbRgK7HCwGTE2Gqw.md @@ -1 +1,16 @@ -# PSR Standards \ No newline at end of file +# PSR Standards + +The PHP Framework Interop Group (PHP-FIG) introduced PHP Standard Recommendation (PSR) standards to provide a uniform and interoperable set of coding practices for PHP developers. PSR standards cover a variety of coding aspects such as code style (PSR-1, PSR-2), autoloading (PSR-4), and more. The PHP community widely accepts these standards contributing towards writing clean and easy-to-follow code. Here's a snippet to illustrate the PSR-4 autoloading standards in PHP: +```php +// Register the autoloader +spl_autoload_register(function ($class) { + // Convert namespace to directory structure + $class = str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php'; + + // Get file if it exists + if (file_exists($class)) { + require $class; + } +}); +``` +You can probe into PSR's details by visiting the official [PHP-FIG website](https://www.php-fig.org/psr/). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/reading-files@S9wTlkbv9-R6dohhZ47hs.md b/src/data/roadmaps/php/content/reading-files@S9wTlkbv9-R6dohhZ47hs.md index 5a27ad18a..b463d140e 100644 --- a/src/data/roadmaps/php/content/reading-files@S9wTlkbv9-R6dohhZ47hs.md +++ b/src/data/roadmaps/php/content/reading-files@S9wTlkbv9-R6dohhZ47hs.md @@ -1 +1,18 @@ -# Reading Files \ No newline at end of file +# Reading Files + +Reading files is a common task in PHP and it provides a range of functions for this purpose. You can use the `fopen()` function with the 'r' mode to open a file for reading. The `fgets()` function lets you read a file line by line, while `fread()` reads a specified number of bytes. For reading the entire file in one go, use `file_get_contents()`. Remember to always close the file after you're done with `fclose()`. + +Here's a small example using `fgets()`: + +```PHP +$file = fopen("example.txt", "r"); +if ($file) { + while (($line = fgets($file)) !== false) { + echo $line; + } + fclose($file); +} else { + echo 'Error opening file'; +} +``` +Check the [official PHP documentation](https://www.php.net/manual/en/book.filesystem.php) for more information on file system functions. \ No newline at end of file diff --git a/src/data/roadmaps/php/content/recursion@D9ybK5INH5zSOcYMb5ZPi.md b/src/data/roadmaps/php/content/recursion@D9ybK5INH5zSOcYMb5ZPi.md index a27651655..c6aa81e84 100644 --- a/src/data/roadmaps/php/content/recursion@D9ybK5INH5zSOcYMb5ZPi.md +++ b/src/data/roadmaps/php/content/recursion@D9ybK5INH5zSOcYMb5ZPi.md @@ -1 +1,15 @@ -# Recursion \ No newline at end of file +# Recursion + +Recursion, as it applies to PHP, refers to a function that calls itself to solve a problem. A recursive function distinguishes itself by solving small parts of the problem until it resolves the main issue. Think of it as breaking down a task into smaller tasks that are easier to solve. However, careful design is needed to ensure the recursive function has a clear stopping point, or else it can result in an infinite loop. Here's a quick example of a simple recursive function in PHP: + +```php +function countDown($count) { + echo $count; + if($count > 0) { + countDown($count - 1); + } +} +countDown(5); +``` + +In this example, the function `countDown` calls itself until the count hits zero, displaying numbers from 5 to 0. To learn more about recursive functions, the PHP documentation is a helpful resource. Here's a direct link to it: [PHP Documentation](https://www.php.net/manual/en/language.functions.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/require@Kaaqu-mN7xvHN6CbIn616.md b/src/data/roadmaps/php/content/require@Kaaqu-mN7xvHN6CbIn616.md index 3bac3aa2c..fa2fc0e75 100644 --- a/src/data/roadmaps/php/content/require@Kaaqu-mN7xvHN6CbIn616.md +++ b/src/data/roadmaps/php/content/require@Kaaqu-mN7xvHN6CbIn616.md @@ -1 +1,3 @@ -# require \ No newline at end of file +# require + +The 'require' statement is a built-in feature of PHP used to include and evaluate a specific file while executing the code. This is a crucial part of file handling in PHP because it enables the sharing of functions, classes, or elements across multiple scripts, promoting code reusability and neatness. Keep in mind, if the required file is missing, PHP will produce a fatal error and stop the code execution. The basic syntax is `require 'filename';`. For more insights into 'require', visit the PHP documentation [here](https://www.php.net/manual/en/function.require.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/require_once@-CyJbsg2ho3RvfzKnJj5C.md b/src/data/roadmaps/php/content/require_once@-CyJbsg2ho3RvfzKnJj5C.md index 13230055f..8fbe00790 100644 --- a/src/data/roadmaps/php/content/require_once@-CyJbsg2ho3RvfzKnJj5C.md +++ b/src/data/roadmaps/php/content/require_once@-CyJbsg2ho3RvfzKnJj5C.md @@ -1 +1,13 @@ -# require_once \ No newline at end of file +# require_once + +PHP uses the 'require_once' statement as an efficient way to include a PHP file into another one. There's an interesting quirk to this function: PHP checks if the file was previously included, and if so, it doesn't include the file again. This helps avoid problems with redundant function declarations, variable value reassignments, or coding loops. However, do remember that 'require_once' is distinct from 'include_once'. The key difference lies in error handling: if the file specified in 'require_once' cannot be found, PHP will emit a fatal error and halt script execution. Whereas, 'include_once', will only generate a warning. + +Here's how you can utilize 'require_once': + +```php + +``` + +This code fetches all the functions and codes from 'somefile.php' and includes them in the current file. You can check more about this statement on the official PHP documentation: [require_once](https://www.php.net/manual/en/function.require-once.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/sanitization-techniques@tfC1tCrbvH5J43WUpG9Yb.md b/src/data/roadmaps/php/content/sanitization-techniques@tfC1tCrbvH5J43WUpG9Yb.md index c2e0d178f..fff6680c7 100644 --- a/src/data/roadmaps/php/content/sanitization-techniques@tfC1tCrbvH5J43WUpG9Yb.md +++ b/src/data/roadmaps/php/content/sanitization-techniques@tfC1tCrbvH5J43WUpG9Yb.md @@ -1 +1,11 @@ -# Sanitization Techniques \ No newline at end of file +# Sanitization Techniques + +Sanitization Techniques is a vital part of PHP security basics, which ensures that the user-provided data is safe to be used within your script. It can prevent harmful data from being inserted into the database or being used in other ways that could potentially be dangerous to your application. It includes functions which can strip off unwanted characters from the data. For instance, the `filter_var()` function in PHP can be applied to sanitize text. + +```php +$dirty_data = "We love PHP!
"; +$clean_data = filter_var($dirty_data, FILTER_SANITIZE_STRING); +echo $clean_data; +``` + +This will effectively remove any malicious scripts from the text. Take a look at the resource in the [PHP documentation](https://www.php.net/manual/en/function.filter-var.php) for more details. \ No newline at end of file diff --git a/src/data/roadmaps/php/content/sessions@qobzzgzArNHLLn9Oiqc6G.md b/src/data/roadmaps/php/content/sessions@qobzzgzArNHLLn9Oiqc6G.md index cc699719a..977f98cf6 100644 --- a/src/data/roadmaps/php/content/sessions@qobzzgzArNHLLn9Oiqc6G.md +++ b/src/data/roadmaps/php/content/sessions@qobzzgzArNHLLn9Oiqc6G.md @@ -1 +1,3 @@ -# Sessions \ No newline at end of file +# Sessions + +Sessions provide a way to preserve certain data across subsequent accesses. Unlike a cookie, the information is not stored on the user's computer but on the server. This is particularly useful when you want to store information related to a specific user's session on your platform, like user login status or user preferences. When a session is started in PHP, a unique session ID is generated for the user. This ID is then passed and tracked through a cookie in the user's browser. To start a session, you would use the PHP function session_start(). To save a value in a session, you'd use the $_SESSION superglobal array. For example, `$_SESSION['username'] = 'John';` assigns 'John' to the session variable 'username'. Official PHP documentation pertaining to sessions can be found at [PHP.net](https://www.php.net/manual/en/book.session.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/sql-injection@801vB_JMas4ucriUmfrLg.md b/src/data/roadmaps/php/content/sql-injection@801vB_JMas4ucriUmfrLg.md index ee4638946..3fa73443b 100644 --- a/src/data/roadmaps/php/content/sql-injection@801vB_JMas4ucriUmfrLg.md +++ b/src/data/roadmaps/php/content/sql-injection@801vB_JMas4ucriUmfrLg.md @@ -1 +1,3 @@ -# SQL Injection \ No newline at end of file +# SQL Injection + +SQL Injection is a crucial security topic in PHP. It is a code injection technique where an attacker may slip shady SQL code within a query. This attack can lead to data manipulation or loss and even compromise your database. To prevent this, PHP encourages the use of prepared statements with either the MySQLi or PDO extension. An example of a vulnerable code snippet would be: `$unsafe_variable = $_POST['user_input']; mysqli_query($link, "INSERT INTO `table` (`column`) VALUES ('$unsafe_variable')");`. Stop falling prey to injections by utilizing prepared statement like so: `$stmt = $pdo->prepare('INSERT INTO `table` (`column`) VALUES (?)'); $stmt->execute([$safe_variable]);`. For more secure PHP coding style, check out the PHP documentation's section on SQL injection: [https://www.php.net/manual/en/security.database.sql-injection.php](https://www.php.net/manual/en/security.database.sql-injection.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/state-management@CGehmZjcgTWC7fQAvxmNW.md b/src/data/roadmaps/php/content/state-management@CGehmZjcgTWC7fQAvxmNW.md index f920d142d..55c87501d 100644 --- a/src/data/roadmaps/php/content/state-management@CGehmZjcgTWC7fQAvxmNW.md +++ b/src/data/roadmaps/php/content/state-management@CGehmZjcgTWC7fQAvxmNW.md @@ -1 +1,3 @@ -# State Management \ No newline at end of file +# State Management + +State management in PHP involves keeping track of user activity in the application, as HTTP protocol doesn't store earlier interactions. Typically, these data involve user details such as login info, form input data, etc. A prevalent method of state management in PHP is through sessions and cookies. Sessions work by keeping the state data on the server side and a session identifier on the client side. Note, session's info remains active until the user's session expires. On the other hand, cookies store data on the client side, having an expiry date or until the user deletes them. Here's how to set a cookie in PHP: `setcookie("test_cookie", "test", time() + 3600, '/');`. To access sessions, use the `_SESSION` superglobal array: `$_SESSION["favcolor"] = "green";`. To learn more, refer to the PHP documentation at https://php.net/manual/en/session.examples.basic.php and https://php.net/manual/en/function.setcookie.php. \ No newline at end of file diff --git a/src/data/roadmaps/php/content/static-analysis@PrG_5dyBblXsWYYRcOJMa.md b/src/data/roadmaps/php/content/static-analysis@PrG_5dyBblXsWYYRcOJMa.md index d421ab9b7..1f6f9f32a 100644 --- a/src/data/roadmaps/php/content/static-analysis@PrG_5dyBblXsWYYRcOJMa.md +++ b/src/data/roadmaps/php/content/static-analysis@PrG_5dyBblXsWYYRcOJMa.md @@ -1 +1,10 @@ -# Static Analysis \ No newline at end of file +# Static Analysis + +Static analysis in PHP is a method to inspect the source code before running it. Rather than testing programs on specific inputs (dynamic analysis), static analysis focuses on finding potential issues within code without executing it. It can help in identifying common coding mistakes and uncovering complex problems like dependency issues, unused variables, undeclared properties, and more. Using tools such as PHPStan or Psalm provides this static analysis feature in PHP. For instance, using PHPStan involves merely installing it via Composer and running it against your codebase. + +```bash +composer require --dev phpstan/phpstan +./vendor/bin/phpstan analyse src +``` + +It outputs information about any issues it finds in code. However, to reap the full benefits, understand that these tools require proper configuration and regular usage. Visit the [official PHPStan documentation](https://phpstan.org/user-guide/getting-started) to learn more about static analysis in PHP. The ultimate goal is clean, reliable, and maintainable code. \ No newline at end of file diff --git a/src/data/roadmaps/php/content/static-methods-and-properties@qlkpwXfOc1p7j37hrzffI.md b/src/data/roadmaps/php/content/static-methods-and-properties@qlkpwXfOc1p7j37hrzffI.md index dfb09180e..3a67a7f83 100644 --- a/src/data/roadmaps/php/content/static-methods-and-properties@qlkpwXfOc1p7j37hrzffI.md +++ b/src/data/roadmaps/php/content/static-methods-and-properties@qlkpwXfOc1p7j37hrzffI.md @@ -1 +1,17 @@ -# Static Methods and Properties \ No newline at end of file +# Static Methods and Properties + +Static methods and properties in PHP belong to the class rather than an instance of the class. This means they can be accessed without creating an object of the class. A static method is declared with the static keyword and can be invoked directly using the class name followed by the scope resolution operator. Similarly, a static property is also defined with the static keyword, but cannot be accessed directly, even from within the class methods - they must be accessed through static methods. Here's a simple example: + +```php +class MyClass { + static $myStaticProperty = "Hello, world"; + + static function myStaticMethod() { + return self::$myStaticProperty; + } +} + +echo MyClass::myStaticMethod(); +``` + +In this example, we're directly accessing `myStaticMethod` from `MyClass` without an instantiation. For more detail, check out the PHP documentation [here](https://www.php.net/manual/en/language.oop5.static.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/style-tools@6eWgZVLV479oQzl0fu-Od.md b/src/data/roadmaps/php/content/style-tools@6eWgZVLV479oQzl0fu-Od.md index 30ad4cba5..2ab953e82 100644 --- a/src/data/roadmaps/php/content/style-tools@6eWgZVLV479oQzl0fu-Od.md +++ b/src/data/roadmaps/php/content/style-tools@6eWgZVLV479oQzl0fu-Od.md @@ -1 +1,3 @@ -# Style Tools \ No newline at end of file +# Style Tools + +Style Tools in PHP primarily refer to coding standard tools that help maintain a consistent coding style throughout your PHP project. PHP_CodeSniffer is a popular tool in this category. It tokenizes PHP, JavaScript, and CSS files and detects violations of a defined set of coding standards. A brief example of PHP_CodeSniffer usage would be to run it in the command line like this: `phpcs /path/to/code/myfile.php`. Other tools such as PHP CS Fixer can automatically correct coding standard violations. Here's the PHP documentation link for more details: [PHP Coding Standards](https://www.php.net/manual/en/refs.basic.php.cs.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/switch@bgJ9-m6Fiu3VCc-NZlbpn.md b/src/data/roadmaps/php/content/switch@bgJ9-m6Fiu3VCc-NZlbpn.md index 80b4fcb4e..e884f3054 100644 --- a/src/data/roadmaps/php/content/switch@bgJ9-m6Fiu3VCc-NZlbpn.md +++ b/src/data/roadmaps/php/content/switch@bgJ9-m6Fiu3VCc-NZlbpn.md @@ -1 +1,24 @@ -# switch \ No newline at end of file +# switch + +The switch statement is a special conditional statement in PHP that can simplify code and improve readability when you need to compare one value with multiple different possibilities. It is an alternative to using a chain of "if...else" conditions, and is particularly useful when you have many different cases to compare. The switch expression is evaluated only once, and its value is compared to each case. When a match is found, PHP executes the associated code block. + +Here's a basic switch statement: + +```php +$fruit = "apple"; +switch ($fruit) { + case "apple": + echo "You chose apple."; + break; + case "banana": + echo "You chose banana."; + break; + default: + echo "Invalid choice."; +} +// Outputs: You chose apple. +``` + +Switch statements can make your code cleaner and easier to manage, especially when dealing with multiple conditions. + +For more information, see the PHP documentation: [PHP: switch - Manual](https://www.php.net/manual/en/control-structures.switch.php) diff --git a/src/data/roadmaps/php/content/symfony@57VSMVePOr9qUD5x_LNdf.md b/src/data/roadmaps/php/content/symfony@57VSMVePOr9qUD5x_LNdf.md index 478d4aa9b..dd42a830d 100644 --- a/src/data/roadmaps/php/content/symfony@57VSMVePOr9qUD5x_LNdf.md +++ b/src/data/roadmaps/php/content/symfony@57VSMVePOr9qUD5x_LNdf.md @@ -1 +1,9 @@ -# Symfony \ No newline at end of file +# Symfony + +Symfony is a set of PHP components and a framework for web projects. It aims to speed up the creation and maintenance of web applications and replace the recurring coding tasks. Symfony uses Composer, a PHP dependency manager, to manage its components. Below is an example of creating a new Symfony project: + +```php +composer create-project symfony/website-skeleton myproject +``` + +This will download and install a new Symfony project in the 'myproject' directory. Symfony's components are reusable PHP libraries that will help you complete tasks, like routing, templating, or even creating form handling. More details can be found in the Symfony documentation: https://symfony.com/doc/current/index.html. \ No newline at end of file diff --git a/src/data/roadmaps/php/content/traits@GR09ns9B-0cONQaQ_uj-7.md b/src/data/roadmaps/php/content/traits@GR09ns9B-0cONQaQ_uj-7.md index d67a15118..3859f78af 100644 --- a/src/data/roadmaps/php/content/traits@GR09ns9B-0cONQaQ_uj-7.md +++ b/src/data/roadmaps/php/content/traits@GR09ns9B-0cONQaQ_uj-7.md @@ -1 +1,18 @@ -# Traits \ No newline at end of file +# Traits + +Traits is a concept in PHP that allows code reusability by enabling developers to create reusable pieces of code which can be used in classes to extend functionality. They are a way to reduce intricacies of single inheritance by enabling a developer to reuse sets of methods freely in several independent classes. Here's an example how to use a Trait: + +```php +trait Greeting { + public function sayHello() { + return "Hello"; + } +} +class User { + use Greeting; +} +$user = new User(); +echo $user->sayHello(); // Outputs: Hello +``` + +In the above code snippet, the `Greeting` trait is being used in the `User` class, and we are able to use its methods as if they were defined in the `User` class. Please consult the PHP documentation for more detailed information: [PHP Trait Documentation](https://www.php.net/manual/en/language.oop5.traits.php). diff --git a/src/data/roadmaps/php/content/type-declarations@sPW-Ti2VyNYzxq6EYkbn7.md b/src/data/roadmaps/php/content/type-declarations@sPW-Ti2VyNYzxq6EYkbn7.md index ec9f92b1c..cf6548d82 100644 --- a/src/data/roadmaps/php/content/type-declarations@sPW-Ti2VyNYzxq6EYkbn7.md +++ b/src/data/roadmaps/php/content/type-declarations@sPW-Ti2VyNYzxq6EYkbn7.md @@ -1 +1,12 @@ -# Type Declarations \ No newline at end of file +# Type Declarations + +Type declarations, also known as type hints, are a feature in PHP that provides you options to specify the type of variable that a function is expected to receive or the type of value that it should return. Not only does it help to debug code quickly, it also makes the code more readable. In PHP, type declarations can be for both parameters in a function (parameter type declarations) and return values from a function (return type declarations). They can apply to classes, interfaces, callable, and scalar types (int, float, string, bool). Here's an example: + +```php +function add(int $a, int $b): int { + return $a + $b; +} + +echo add(1, 2); // prints: 3 +``` +In this example, the function 'add' only accepts integers and also returns an integer. The PHP documentation provides more details: [PHP Manual: Function Arguments & ReturnType Declarations](https://www.php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration) diff --git a/src/data/roadmaps/php/content/var_dump@JCCeVC0hOrvIeyfg1ScKA.md b/src/data/roadmaps/php/content/var_dump@JCCeVC0hOrvIeyfg1ScKA.md index ea65a06f6..db3016fbe 100644 --- a/src/data/roadmaps/php/content/var_dump@JCCeVC0hOrvIeyfg1ScKA.md +++ b/src/data/roadmaps/php/content/var_dump@JCCeVC0hOrvIeyfg1ScKA.md @@ -1 +1,10 @@ -# var_dump \ No newline at end of file +# var_dump + +Var_dump is a built-in PHP function that's incredibly handy for debugging as it outputs the data type and value of a given variable. This includes array elements and object properties, if given such types. If you're wrangling with your PHP code and finding your variables aren't behaving as you expect, using var_dump can quickly show you what you're working with. Check out a simple usage example below: + +```php +$myVar = array( "Hello", "World!"); +var_dump($myVar); +``` + +This will output the size of array and details of each element in the array. You can find more examples and usage scenarios on the [PHP official documentation](https://www.php.net/manual/en/function.var-dump.php). diff --git a/src/data/roadmaps/php/content/variables-and-scope@D0BtyxyjIBcpfn5wP23WC.md b/src/data/roadmaps/php/content/variables-and-scope@D0BtyxyjIBcpfn5wP23WC.md index 14fb7ceb9..ec5b8b824 100644 --- a/src/data/roadmaps/php/content/variables-and-scope@D0BtyxyjIBcpfn5wP23WC.md +++ b/src/data/roadmaps/php/content/variables-and-scope@D0BtyxyjIBcpfn5wP23WC.md @@ -1 +1,14 @@ -# Variables and Scope \ No newline at end of file +# Variables and Scope + +Variables are a central part of PHP, allowing you to store data that can be used later in your scripts. Their values can be of various types including strings, integers, arrays, and objects. PHP has both local and global scope when it comes to variables. Local scope refers to variables that are only accessible within the function they are defined, while global scope means a variable is accessible to any part of the script. However, to use a global variable inside a function, you need to declare it as global. Here's a brief example: + +```php +$x = 10; //global variable +function test() { + global $x; // accessing the global variable + echo $x; +} +test(); //prints 10 +``` + +For further understanding on the topic, this link to PHP's official documentation can be useful: [PHP: Variables Scope](https://www.php.net/manual/en/language.variables.scope.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/variadic-functions@rtmytETfyyLdcXUC0QyzL.md b/src/data/roadmaps/php/content/variadic-functions@rtmytETfyyLdcXUC0QyzL.md index 99c6f9c6e..d62a9042b 100644 --- a/src/data/roadmaps/php/content/variadic-functions@rtmytETfyyLdcXUC0QyzL.md +++ b/src/data/roadmaps/php/content/variadic-functions@rtmytETfyyLdcXUC0QyzL.md @@ -1 +1,10 @@ -# Variadic Functions \ No newline at end of file +# Variadic Functions + +Variadic functions in PHP are functions that can accept any number of arguments. This gives you greater flexibility, as it allows for an undetermined number of arguments. You can create a variadic function by adding '...' before the function argument. Any number of arguments you provide when calling the function are treated as an array, which can be processed using common array functions. A simple code example: +```php +function sum(...$numbers) { + return array_sum($numbers); +} +echo sum(1, 2, 3, 4); +``` +This prints "10". The function accepts any number of arguments and adds them together. You can refer to the PHP manual at php.net for more details on variadic functions. https://www.php.net/manual/en/functions.arguments.php#functions.variable-arg-list \ No newline at end of file diff --git a/src/data/roadmaps/php/content/wamp@36Y1HkHxhuxh2qVQB8NVE.md b/src/data/roadmaps/php/content/wamp@36Y1HkHxhuxh2qVQB8NVE.md index a2c2bfac9..214165abe 100644 --- a/src/data/roadmaps/php/content/wamp@36Y1HkHxhuxh2qVQB8NVE.md +++ b/src/data/roadmaps/php/content/wamp@36Y1HkHxhuxh2qVQB8NVE.md @@ -1 +1,3 @@ -# WAMP \ No newline at end of file +# WAMP + +WAMP is a popular software stack used for developing PHP web applications on Windows systems. Acting as an abbreviation for Windows, Apache, MySQL, and PHP, WAMP provides all the components necessary to set up a local web server. Apache is used to handle HTTP requests, MySQL manages the databases, and PHP serves as the programming language. The benefit of using WAMP lies in its convenience as it pre-packages all these components, saving time for the developer. You can download WAMP from its official website, then after installation, testing of your PHP scripts can be done locally without needing an internet connection. Refer to the [official PHP documentation](https://www.php.net/manual/en/install.windows.manual.php) for more details on setting up a PHP environment on Windows. \ No newline at end of file diff --git a/src/data/roadmaps/php/content/what-is-php@_LhLDVZjLt1DoAP1NuUES.md b/src/data/roadmaps/php/content/what-is-php@_LhLDVZjLt1DoAP1NuUES.md index bf932cd53..b7ae47615 100644 --- a/src/data/roadmaps/php/content/what-is-php@_LhLDVZjLt1DoAP1NuUES.md +++ b/src/data/roadmaps/php/content/what-is-php@_LhLDVZjLt1DoAP1NuUES.md @@ -1 +1,3 @@ -# What is PHP? \ No newline at end of file +# What is PHP? + +PHP, an acronym for Hypertext Preprocessor, is a popular server-side scripting language favored for web development. It's versatile, dynamic, and can be embedded seamlessly into HTML code. PHP scripts are executed on the server, and the result is sent back to the browser as plain HTML. For example, a basic PHP script to display "Hello, World!" on a webpage would look like this - ``. You can learn more about PHP by reading the official PHP documentation [here](https://www.php.net/manual/en/intro-whatis.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/writing-files@two4UycJaCfSp6jQqtTAb.md b/src/data/roadmaps/php/content/writing-files@two4UycJaCfSp6jQqtTAb.md index 344ed1208..6329ae23d 100644 --- a/src/data/roadmaps/php/content/writing-files@two4UycJaCfSp6jQqtTAb.md +++ b/src/data/roadmaps/php/content/writing-files@two4UycJaCfSp6jQqtTAb.md @@ -1 +1,12 @@ -# Writing Files \ No newline at end of file +# Writing Files + +Writing files plays a crucial part in PHP, allowing you to store data and modify it later. This process involves opening the file, writing the desired data, and then closing it. Writing can be done using different functions, but 'fwrite' is the most commonly used one. It requires two arguments the file pointer and the string of data to be written. Here's a brief snippet of code for instance: + +```php +$file = 'data.txt'; +$current = file_get_contents($file); +$current .= "New Data\n"; +file_put_contents($file, $current); +``` + +In this code, file_get_contents() is used to get the current data, then new data is appended, and file_put_contents() is used to write back to the file. Do revisit the official PHP documentation to understand the nuances of file writing in PHP - [Writing to Files](https://www.php.net/manual/en/function.fwrite.php). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/xampp@-wniKEBwbF0Fi1fHpF-Gc.md b/src/data/roadmaps/php/content/xampp@-wniKEBwbF0Fi1fHpF-Gc.md index 0f6314e9d..63f65b1ee 100644 --- a/src/data/roadmaps/php/content/xampp@-wniKEBwbF0Fi1fHpF-Gc.md +++ b/src/data/roadmaps/php/content/xampp@-wniKEBwbF0Fi1fHpF-Gc.md @@ -1 +1,3 @@ -# XAMPP \ No newline at end of file +# XAMPP + +XAMPP is an open-source development environment that stands for Cross-Platform (X), Apache server (A), MariaDB (M), PHP (P), and Perl (P). If you're working with PHP, it's a handy tool because it creates a local web server for testing or development purposes. It's especially useful if you plan to use a database in your project, as it includes MariaDB. It integrates seamlessly with PHP, enabling you to manage your server, scripting language, and database from a unified platform with less hassle. A code sample isn't really applicable here as XAMPP is more about setup and management. For more information, you can visit the official PHP documentation: https://www.php.net/manual/en/install.php. \ No newline at end of file diff --git a/src/data/roadmaps/php/content/xdebug@lFoHoMRywCWa056ii5cKQ.md b/src/data/roadmaps/php/content/xdebug@lFoHoMRywCWa056ii5cKQ.md index a15f512c6..bd61e7837 100644 --- a/src/data/roadmaps/php/content/xdebug@lFoHoMRywCWa056ii5cKQ.md +++ b/src/data/roadmaps/php/content/xdebug@lFoHoMRywCWa056ii5cKQ.md @@ -1 +1,15 @@ -# Xdebug \ No newline at end of file +# Xdebug + +Xdebug is a PHP extension that provides debugging and profiling capabilities. It's a powerful tool that can help you understand what your code is doing, track down bugs, and optimize performance. With Xdebug, you can set breakpoints, watch variables, and step through your code one line at a time. For instance, to start using Xdebug, you first need to install it and then initialize it in your code like so: + +```php + +``` +Xdebug can significantly speed up bug-tracking and testing, making it an essential tool in any PHP developer's toolkit. For more in-depth information and usage guides, refer to the official documentation at [Xdebug's Official Site](https://xdebug.org/docs/). \ No newline at end of file diff --git a/src/data/roadmaps/php/content/xml-processing@ggkWo0DRSSDDkHpbiyUyf.md b/src/data/roadmaps/php/content/xml-processing@ggkWo0DRSSDDkHpbiyUyf.md index 3a11834e7..8377a1958 100644 --- a/src/data/roadmaps/php/content/xml-processing@ggkWo0DRSSDDkHpbiyUyf.md +++ b/src/data/roadmaps/php/content/xml-processing@ggkWo0DRSSDDkHpbiyUyf.md @@ -1 +1,12 @@ -# XML Processing \ No newline at end of file +# XML Processing + +XML processing in PHP allows manipulation and interpretation of XML documents. PHP's XML Parser extension helps to parse XML data from strings and files, providing event-driven processing capabilities. This is especially useful during large XML parsing. To process XML in PHP, you first create an XML parser, set functionality through handler functions for the start and end of elements, character data, etc., and then parse the XML data. The `xml_parser_create()`, `xml_set_element_handler()`, `xml_parse()`, and `xml_parser_free()` functions come into play here. Here's a brief snippet showing XML parsing in PHP: + +```php +$parser = xml_parser_create(); +xml_set_element_handler($parser, "startElement", "endElement"); +xml_parse($parser, $xml_data); +xml_parser_free($parser); +``` + +Look into PHP's official documentation on XML Parser for more details: https://www.php.net/manual/en/book.xml.php. \ No newline at end of file diff --git a/src/data/roadmaps/php/content/xss-prevention@DxqQrToZSayWplKdCkTgT.md b/src/data/roadmaps/php/content/xss-prevention@DxqQrToZSayWplKdCkTgT.md index c6a51bcef..b3e40b0f1 100644 --- a/src/data/roadmaps/php/content/xss-prevention@DxqQrToZSayWplKdCkTgT.md +++ b/src/data/roadmaps/php/content/xss-prevention@DxqQrToZSayWplKdCkTgT.md @@ -1 +1,13 @@ -# XSS Prevention \ No newline at end of file +# XSS Prevention + +Cross Site Scripting, often known as XSS, is a glaring risk in web security, and PHP also must address it. It occurs when someone is able to insert dangerous code into your site, which can then be executed by users. To prevent XSS in PHP, developers should deploy htmlspecialchars() function to escape potentially harmful characters. This function converts special characters to their HTML entities, reducing risk. For instance, '<' becomes '<'. + +Sample PHP code to implement this: + +``` +$secure_text = htmlspecialchars($raw_text, ENT_QUOTES, 'UTF-8'); +``` + +In this code, $raw_text contains user input that might be risky. By using htmlspecialchars(), $secure_text will now hold a sanitized version of the user input. + +Find more on this topic in the PHP documentation. [https://www.php.net/manual/en/function.htmlspecialchars.php](https://www.php.net/manual/en/function.htmlspecialchars.php) \ No newline at end of file diff --git a/src/data/roadmaps/php/content/zend-debugger@KpQb5Zh3GUcbYUyXHvyu2.md b/src/data/roadmaps/php/content/zend-debugger@KpQb5Zh3GUcbYUyXHvyu2.md index 0544b7a23..229f9b9db 100644 --- a/src/data/roadmaps/php/content/zend-debugger@KpQb5Zh3GUcbYUyXHvyu2.md +++ b/src/data/roadmaps/php/content/zend-debugger@KpQb5Zh3GUcbYUyXHvyu2.md @@ -1 +1,3 @@ -# Zend Debugger \ No newline at end of file +# Zend Debugger + +Zend Debugger is a PHP debugging extension used to identify issues in PHP scripts. It allows you to monitor and fix issues in your code, such as logical errors, and helps in boosting your web application's overall performance. Essentially, it becomes a simple yet powerful method for debugging server-side PHP scripts, by providing detailed debugging data and facilitating real-time interaction with the scripts. Using Zend Debugger with PHP can drastically improve the quality of your codebase and save considerable time in the development phase. A short usage example of Zend Debugger can be setting up a debug session, using the function 'zend_debugger_connector_address()' which returns the IP address of the debugger currently in use. Developer documentation for Zend Debugger can be found [here](https://www.zend.com/topics/Debugger-API). \ No newline at end of file