\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Ady G (AdyG)} \pdfinfo{ /Title (cakephp-3-bake.pdf) /Creator (Cheatography) /Author (Ady G (AdyG)) /Subject (CakePHP 3 Bake Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{417282} \definecolor{LightBackground}{HTML}{F3F6F7} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{CakePHP 3 Bake Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Ady G (AdyG)} via \textcolor{DarkBackground}{\uline{cheatography.com/27542/cs/8008/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Ady G (AdyG) \\ \uline{cheatography.com/adyg} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 13th May, 2016.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{CakePHP Console Cheat Sheet}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/adyg_1461601707_Cake-PHP-Logo-Gradient-Background.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\emph{Details extracted from CakePHP 3.2.x command prompt.}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Installation}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`composer require -{}-dev cakephp/bake:\textasciitilde{}1.0`} \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{PhpStorm comes with {\bf{composer}} built in. \{\{nl\}\}To install CakePHP via PhpStorm, use the File\{\{fa-arrow-right\}\}New\{\{fa-arrow-right\}\}Composer Project. \{\{nl\}\}Then filter for {\emph{CakePHP}} and select the `cakephp\textbackslash{}app` composer project.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{CakePHP Console}} \tn % Row 0 \SetRowColor{LightBackground} Run the CakePHP console from project root & `bin/cake` {\emph{(use `bin\textbackslash{}cake` for Windows)}} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Possible "shells" & `bake`, `migrations`, `i18n`, `orm\_cache`, `plugin`, `routes`, `server`, `behavior\_time`, `console`, `orm` \tn % Row Count 9 (+ 6) % Row 2 \SetRowColor{LightBackground} Run Cake Server {\emph{(usually on localhost port 8765)}} & `bin/cake server` \tn % Row Count 12 (+ 3) % Row 3 \SetRowColor{white} Run migrations shell {\emph{(with help)}} & `bin/cake migrations -h` \tn % Row Count 14 (+ 2) % Row 4 \SetRowColor{LightBackground} Run bake with plugin prefix & `bin/cake bake.bake -h` \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{\{\{fa-warning\}\} PHP CLI must be installed and in the path.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{5.2 cm} x{2.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Bake Shell Common Options}} \tn % Row 0 \SetRowColor{LightBackground} help & `-{}-help` or `-h` \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Verbose output & `-{}-verbose` or `-v` \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Quiet output & `-{}-quiet` or `-q` \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Plugin to bake into & `-{}-plugin` or `-p` \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} Force overwrite of existing files & `-{}-force` or `-f` \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} Datasource connection to get data from {\emph{(default: default)}} & `-{}-connection` or `-c` \tn % Row Count 13 (+ 3) % Row 6 \SetRowColor{LightBackground} Theme to use when baking & `-{}-theme` or `-t` \tn % Row Count 15 (+ 2) % Row 7 \SetRowColor{white} Do not bake a test skeleton & `-{}-no-test` \tn % Row Count 17 (+ 2) % Row 8 \SetRowColor{LightBackground} Do not bake generic CRUD action methods & `-{}-no-actions` \tn % Row Count 19 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{\{\{fa-info-circle\}\} These options are common to most of the cake shell commands.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Server Shell}} \tn % Row 0 \SetRowColor{LightBackground} Run server shell with {\emph{(defaults)}} & `bin/cake server` \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Run server shell and get help & `bin/cake server -{}-help` \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Run server shell on port 9999 & `bin/cake server -{}-port 9999` \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Run server shell using IP of 10.0.0.2 & `bin/cake server -{}-host 10.0.0.2` \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} Run server shell with document root dummy/app/root & `bin/cake server -{}-document\_root dummy/app/root` \tn % Row Count 11 (+ 3) % Row 5 \SetRowColor{white} Run server shell with verbose output & `bin/cake server -{}-verbose` \tn % Row Count 13 (+ 2) % Row 6 \SetRowColor{LightBackground} \{\{fa-ellipsis-h\}\} example & `bin/cake -H 10.0.0.2 -p 9999 -d dummy/app/root -v` \tn % Row Count 16 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Bake Shell: Model}} \tn % Row 0 \SetRowColor{LightBackground} Run bake model shell and list all tables & `bin/cake bake model` \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Bake model class for Friends table & `bin/cake bake model Friends` \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Run bake model shell and get help & `bin/cake bake model -{}-help` \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Generalised use: & `bin/cake bake model {\emph{ {\bf{{[}}}subcommand{\bf{{]} {[}}}options{\bf{{]} {[}}}\textless{}ModelName\textgreater{}{\bf{{]}}} }}` \tn % Row Count 10 (+ 4) % Row 4 \SetRowColor{LightBackground} {\bf{Options}} & {\emph{other than the default ones}} \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} Table name if "non-conventional" table naming used & `-{}-table {\emph{\textless{}TableName\textgreater{}}}` \tn % Row Count 15 (+ 3) % Row 6 \SetRowColor{LightBackground} Disable generation of Entity class & `-{}-no-entity` \tn % Row Count 17 (+ 2) % Row 7 \SetRowColor{white} Disable generation of Table class & `-{}-no-table` \tn % Row Count 19 (+ 2) % Row 8 \SetRowColor{LightBackground} Disable generation of validation rules & `-{}-no-validation` \tn % Row Count 21 (+ 2) % Row 9 \SetRowColor{white} Disable generation of a rules checker & `-{}-no-rules` \tn % Row Count 23 (+ 2) % Row 10 \SetRowColor{LightBackground} Disable generatin of associations & `-{}-no-associations` \tn % Row Count 25 (+ 2) % Row 11 \SetRowColor{white} Disable generation of fields & `-{}-no-fields` \tn % Row Count 27 (+ 2) % Row 12 \SetRowColor{LightBackground} Comma separated list of fields to make accessible & `-{}-fields {\emph{\textless{}fieldname\textgreater{}{\bf{{[}}},\textless{}fieldname\textgreater{}...{\bf{{]}}} }}` \tn % Row Count 30 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Bake Shell: Model (cont)}} \tn % Row 13 \SetRowColor{LightBackground} Comma separated list of hidden fields & `-{}-hidden {\emph{\textless{}fieldname\textgreater{}{\bf{{[}}},\textless{}fieldname\textgreater{}...{\bf{{]}}} }}` \tn % Row Count 3 (+ 3) % Row 14 \SetRowColor{white} Set the primary key field or fields (comma separated) & `-{}-primary-key {\emph{\textless{}key-field\textgreater{}{\bf{{[}}},\textless{}key-field\textgreater{}...{\bf{{]}}} }}` \tn % Row Count 6 (+ 3) % Row 15 \SetRowColor{LightBackground} Display field if you would like to select one & `-{}-display-field {\emph{\textless{}field-name\textgreater{}}}` \tn % Row Count 9 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Cake Routes Shell}} \tn % Row 0 \SetRowColor{LightBackground} List of all Routes & `bin/cake routes` \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} URL Parsing Testing & `bin/cake routes check {\emph{route-and-options}}` \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} \{\{fa-ellipsis-h\}\} example & `bin/bake routes check /bookmarks/edit/1` \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} URL Generation Testing & `bin/cake routes generate controller:{\emph{controllername}} action:{\emph{action}} {\emph{other options}}` \tn % Row Count 12 (+ 5) % Row 4 \SetRowColor{LightBackground} \{\{fa-ellipsis-h\}\} example & `bin/cake routes generate \seqsplit{controller:Bookmarks} action:edit 1` \tn % Row Count 16 (+ 4) % Row 5 \SetRowColor{white} \{\{fa-ellipsis-h\}\} example with string parameters & `bin/cake routes check \seqsplit{"/bookmarks/?page=1\&sort=title\&direction=desc"`} \tn % Row Count 20 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Bake Shell: Controller}} \tn % Row 0 \SetRowColor{LightBackground} Bake a controller skeleton & `cake bake controller {\bf{{[}}}subcommand{\bf{{]} {[}}}options{\bf{{]} {[}}}\textless{}name\textgreater{}{\bf{{]}}}` \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} Bake the My controller with CRUD actions & `bin/cake bake controller MyController` \tn % Row Count 6 (+ 2) % Row 2 \SetRowColor{LightBackground} Bake all controllers with CRUD methods\{\{nl\}\}\{\{fa-warning\}\}{\emph{ {\bf{Beware:}} This may overwrite existing controllers}} & `cake bake controller all` \tn % Row Count 12 (+ 6) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{8.4cm}}{{\bf{Options}}} \tn % Row Count 13 (+ 1) % Row 4 \SetRowColor{LightBackground} Plugin to bake into & `-{}-plugin` or `-p` \tn % Row Count 14 (+ 1) % Row 5 \SetRowColor{white} Force overwrite of existing files & `-{}-force` or `-f` \tn % Row Count 16 (+ 2) % Row 6 \SetRowColor{LightBackground} Datasource connection to get data from {\emph{(default: default)}} & `-{}-connection` or `-c` \tn % Row Count 19 (+ 3) % Row 7 \SetRowColor{white} Theme to use when baking & `-{}-theme` or `-t` \tn % Row Count 21 (+ 2) % Row 8 \SetRowColor{LightBackground} Components to use {\emph{(comma separated)}} & `-{}-components` \tn % Row Count 23 (+ 2) % Row 9 \SetRowColor{white} Helpers to use {\emph{(comma separated)}} & `-{}-helpers` \tn % Row Count 25 (+ 2) % Row 10 \SetRowColor{LightBackground} Namespace/routing prefix to use & `-{}-prefix` \tn % Row Count 27 (+ 2) % Row 11 \SetRowColor{white} Do not bake a test skeleton & `-{}-no-test` \tn % Row Count 29 (+ 2) % Row 12 \SetRowColor{LightBackground} Do not bake generic CRUD action methods & `-{}-no-actions` \tn % Row Count 31 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{{\emph{\textless{}name\textgreater{}}} is the name of the controller to bake, and you may use {\emph{Plugin.name}} to bake controllers into plugins (optional).} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{0.912 cm} x{1.672 cm} x{5.016 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Version Control}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Version} & Date & Notes \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} 1.0 & 25 April 2016 & Initial version, there are many more commands to add \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \SetRowColor{LightBackground} \mymulticolumn{3}{x{8.4cm}}{\{\{fa-info-circle\}\} {\emph{This will be updated each time we add new content to the cheat sheet.}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}