Zen Cart Developer Documentation
Total Page:16
File Type:pdf, Size:1020Kb
Zen Cart Developer Documentation Zen Cart Team Jul 24, 2019 Contents 1 Contributing To Zen Cart 3 1.1 Getting Started..............................................3 1.1.1 But What Can I Offer?.....................................3 1.1.2 I’m Scared! This is my first time!...............................3 1.1.3 Where do I start?........................................3 1.2 Coding Standards.............................................4 1.2.1 Old Standard..........................................4 1.2.2 New Standard: PSR-2......................................4 1.2.2.1 Difference from the “Old Standard”..........................4 1.2.3 When to use PSR-2.......................................4 1.2.4 When to use old style......................................5 1.2.5 When to reformat an entire file.................................5 1.2.6 Comments in Code.......................................5 1.2.7 What about files containing both HTML and PHP?......................5 1.2.7.1 Good:.........................................5 1.2.7.2 Bad:..........................................5 1.2.8 Separating content, markup and logic.............................5 1.2.9 Namespaced Autoloading....................................6 1.3 Pull Requests...............................................6 1.3.1 Quick Reference for Newcomers to git or github........................6 1.3.2 Client Applications to Interact with git.............................6 1.3.3 Workflow............................................6 1.3.3.1 Basic setup.......................................7 1.3.3.2 Cloning a repository..................................7 1.3.3.3 Add an upstream remote................................7 1.3.3.4 Making a working-branch...............................8 1.3.3.5 Pick a branch name..................................8 1.3.3.6 Make the branch....................................8 1.3.3.7 Make your code changes...............................8 1.3.3.8 Commits........................................9 1.3.3.9 About Commit Messages............................... 10 1.3.3.10 Pushing Commits To Github............................. 10 1.3.3.11 Pull Request...................................... 10 1.3.3.12 Keeping Your Local Branch Current......................... 11 1.3.3.13 Cleaning up old branches, or grabbing new branches................. 11 1.3.4 References........................................... 12 i 1.4 Reporting Bugs.............................................. 12 1.4.1 Posting the Issue on Github................................... 12 1.4.2 Issue Labels........................................... 13 1.4.3 Reference Guide........................................ 13 1.5 Documentation.............................................. 13 1.5.1 Installing Documentation.................................... 14 1.5.2 Installing Sphinx........................................ 14 1.5.3 Building Documentation.................................... 14 1.5.4 Resources............................................ 14 1.6 Unit Testing............................................... 14 1.6.1 Preparation / Initial Setup.................................... 14 1.6.2 Running Tests.......................................... 15 1.6.3 Running Individual Tests.................................... 15 1.6.4 Adding Tests.......................................... 15 1.6.5 Web Tests............................................ 15 1.6.6 Preparation and Setup for Web Tests.............................. 15 1.6.7 Preparing custom configurations................................ 15 1.6.8 Running Web Tests....................................... 16 2 Developer Documentation 17 2.1 Admin Classes.............................................. 17 2.2 FileSytem Class............................................. 17 2.3 Language Loader Class......................................... 18 2.3.1 Admin Language Loader.................................... 18 2.4 Table View Controllers.......................................... 18 2.4.1 Page Skeleton.......................................... 18 2.4.2 Table Controller Classes.................................... 19 2.4.3 Table Definition Array..................................... 19 2.4.4 colKey.............................................. 20 2.4.5 actions.............................................. 20 2.4.5.1 action......................................... 20 2.4.5.2 text........................................... 20 2.4.5.3 getParams....................................... 20 2.4.5.4 showOnlyOnEmptyAction.............................. 20 2.4.6 defaultRowAction........................................ 20 2.4.7 columns............................................. 21 2.5 Plugin System.............................................. 21 2.5.1 Directory Structure....................................... 21 2.5.2 Manifest Files.......................................... 22 2.5.2.1 pluginType....................................... 22 2.5.2.2 pluginAuthor...................................... 22 2.5.2.3 pluginName...................................... 23 2.5.2.4 pluginDescription................................... 23 2.5.2.5 managed........................................ 23 2.5.2.6 zcVersions....................................... 23 2.5.2.7 pluginGroups..................................... 23 2.5.2.8 @todo......................................... 23 2.5.3 Installer Language Files.................................... 23 2.5.4 Installer Classes......................................... 24 2.5.5 SQL Installation......................................... 24 2.5.5.1 Plain SQL Files.................................... 25 2.5.5.2 Migration Classes................................... 25 2.5.6 Writing Plugins......................................... 25 2.5.6.1 PSR 4 Autoloading.................................. 25 ii 2.5.6.2 Admin Controllers................................... 26 2.5.6.3 InitSystem....................................... 26 2.5.6.4 Support Files...................................... 26 2.5.6.5 Page Files....................................... 27 2.5.6.6 Language Files..................................... 27 2.5.6.7 Template Files..................................... 27 2.5.7 Debugging Plugins....................................... 27 2.5.8 Plugin Manager Class...................................... 27 2.5.8.1 Plugin Manager Public Methods........................... 27 2.6 InitSystem................................................ 27 3 Habitat Developer Environment 29 3.1 Installation................................................ 29 3.1.1 Prerequisites.......................................... 29 3.1.2 Install Habitat.......................................... 30 3.2 Code Development............................................ 30 3.2.1 Passwords............................................ 30 3.3 Customising Habitat........................................... 30 3.3.1 Habitat.yaml Configuration Options.............................. 31 3.4 Development Tools............................................ 33 3.4.1 phpMyAdmin.......................................... 33 3.4.2 Database Backup and Restore................................. 33 3.4.3 Unit Testing........................................... 33 3.4.4 phpDocumentor......................................... 34 3.5 Technical Specifications......................................... 34 3.5.1 Software Installed in Habitat.................................. 34 3.5.2 Updating............................................ 35 3.5.3 Source.............................................. 35 4 Docker Development Environment 37 4.1 Installing Docker............................................. 37 4.2 Installing Devilbox............................................ 37 4.2.1 Customising Devilbox..................................... 37 iii iv Zen Cart Developer Documentation Warning: The documentation here is very much work in progress. It will change as code for v157 evolves. This site contains documentation related to the Zen Cart e-commerce system, and other projects related to Zen Cart. The site is organized into a number of Manuals. The currently available Manuals are: • Contributing To Zen Cart • Developer Documentation • Habitat Developer Environment • Docker Development Environment You may contribute to this documentation via our Github Repository. Contents 1 Zen Cart Developer Documentation 2 Contents CHAPTER 1 Contributing To Zen Cart 1.1 Getting Started 1.1.1 But What Can I Offer? Your experiences will be both the same as hundreds of others and yet uniquely yours at the same time. Your own unique perspective, combined with your own creativity, coupled with your skills and experience, mean you have something to offer! See a bug? Know of an improvement, even if it’s tiny? Feel free to share about it! 1.1.2 I’m Scared! This is my first time! That’s completely understandable. We all started with a sense of excitement and fear all at once. Excitement to be a contributor, and fear that my contribution might be wrong or break something or be rejected. Those are normal feelings. Here’s an excellent article explaining those same feelings and showing how easy it is to get through them! 1.1.3 Where do I start? It’s really as easy as 1-2-3 . 1. Start with reviewing the Reporting Bugs document, as a guide to first steps about exploring the issue further, checking whether it’s already being addressed someplace, whether it’s a core bug vs a “bugs-me bug”, along with how to report the issue to the dev team and community for further discussion using Github Issues or