<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.sandbox.joomla.org/index.php?action=history&amp;feed=atom&amp;title=Framework%3AGetting_Started</id>
	<title>Framework:Getting Started - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://docs.sandbox.joomla.org/index.php?action=history&amp;feed=atom&amp;title=Framework%3AGetting_Started"/>
	<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Framework:Getting_Started&amp;action=history"/>
	<updated>2026-09-19T06:38:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Framework:Getting_Started&amp;diff=778881&amp;oldid=prev</id>
		<title>Alexandreelise: Fix what seems to by a typo Default rather than Defult</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Framework:Getting_Started&amp;diff=778881&amp;oldid=prev"/>
		<updated>2021-01-15T22:14:38Z</updated>

		<summary type="html">&lt;p&gt;Fix what seems to by a typo Default rather than Defult&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:14, 15 January 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l17&quot;&gt;Line 17:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 17:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	$router-&amp;gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;setDefultControllerPrefix&lt;/del&gt;(&#039;App&#039;);&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	$router-&amp;gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;setDefaultControllerPrefix&lt;/ins&gt;(&#039;App&#039;);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	$router-&amp;gt;setDefaultController(&amp;#039;\Controller\DefaultController&amp;#039;);&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	$router-&amp;gt;setDefaultController(&amp;#039;\Controller\DefaultController&amp;#039;);&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Alexandreelise</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Framework:Getting_Started&amp;diff=107264&amp;oldid=prev</id>
		<title>Tom Hutchison: added Category:Framework using HotCat</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Framework:Getting_Started&amp;diff=107264&amp;oldid=prev"/>
		<updated>2014-01-30T12:53:44Z</updated>

		<summary type="html">&lt;p&gt;added &lt;a href=&quot;/Category:Framework&quot; title=&quot;Category:Framework&quot;&gt;Category:Framework&lt;/a&gt; using &lt;a href=&quot;https://en.wikipedia.org/wiki/Help:Gadget-HotCat&quot; class=&quot;extiw&quot; title=&quot;wp:Help:Gadget-HotCat&quot;&gt;HotCat&lt;/a&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 12:53, 30 January 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l80&quot;&gt;Line 80:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 80:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	$app = $this-&amp;gt;getApplication();&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	$app = $this-&amp;gt;getApplication();&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	$db = $app-&amp;gt;db;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	$db = $app-&amp;gt;db;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Framework]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Tom Hutchison</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Framework:Getting_Started&amp;diff=107260&amp;oldid=prev</id>
		<title>Purplebeanie: This page has some Q&amp;A&#039;s for some of the issues I encountered when getting started with the Framework</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Framework:Getting_Started&amp;diff=107260&amp;oldid=prev"/>
		<updated>2014-01-29T23:31:17Z</updated>

		<summary type="html">&lt;p&gt;This page has some Q&amp;amp;A&amp;#039;s for some of the issues I encountered when getting started with the Framework&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;These are some questions and answers that may help make getting started with the Framework easier.&lt;br /&gt;
&lt;br /&gt;
==Why does the router keep throwing &amp;quot;Unable to handle request for route&amp;quot;==&lt;br /&gt;
&lt;br /&gt;
This error is generated when the \Joomla\Router\Router class is unable to find a valid route to match the URL the user has entered.&lt;br /&gt;
&lt;br /&gt;
This could be due to:&lt;br /&gt;
&lt;br /&gt;
* There is no route defined for the resource and the router does not have a defaultController (defined using $router-&amp;gt;setDefaultController(fully namespaces controller name)).  Check to see if a route exists, or the defaultController has been set.  &lt;br /&gt;
* You have not created a .htaccess file to rewrite the URL To remove the index.php component of the URL.  Use the example .htaccess in the framework-app. (https://github.com/dbhurley/framework-app/blob/master/www/.htaccess)&lt;br /&gt;
&lt;br /&gt;
==How do I create a default route when no existing route matches?==&lt;br /&gt;
&lt;br /&gt;
A default controller can be created for the Joomla\Router\Router class.  This is used when no existing route matches the request URI.  &lt;br /&gt;
&lt;br /&gt;
To define a default controller call the \Joomla\Router\Router class setDefaultController function and pass the fully namespaced controller name you wish to use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
	$router-&amp;gt;setDefultControllerPrefix(&amp;#039;App&amp;#039;);&lt;br /&gt;
	$router-&amp;gt;setDefaultController(&amp;#039;\Controller\DefaultController&amp;#039;);&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will attempt to load the DefaultController.php file from the App/Controller directory.  The class name would be DefaultController.&lt;br /&gt;
&lt;br /&gt;
==How can I easily create a lot of routes?==&lt;br /&gt;
&lt;br /&gt;
The \Joomla\Router\Router class has a function addMaps that takes an array of routes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
	$router-&amp;gt;addMaps(my array of routes)&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These can be loaded from an array defined elsewhere or from an external file.  The framework-app (https://github.com/dbhurley/framework-app/) shows how to load these from an external JSON file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
	$router = new Router();&lt;br /&gt;
	$maps = json_decode(file_get_contents(JPATH_CONFIGURATION.&amp;#039;/routes.json&amp;#039;));&lt;br /&gt;
	$router-&amp;gt;addMaps($maps);&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I find creating routes in a routes.json file easier to manage.&lt;br /&gt;
&lt;br /&gt;
==How do I connect to the database from a Controller?==&lt;br /&gt;
&lt;br /&gt;
Connecting to the database is managed through the \Joomla\Database\DatabaseFactory class.  While you could create this each time in each controller this would be extra code to manage for any changes.  I found the easiest way was to create this when bootstrapping the application and maintaining a reference in the AbstractWebApplication class.&lt;br /&gt;
&lt;br /&gt;
Much of this code has been lifted from the Framework-app at (https://github.com/dbhurley/framework-app).&lt;br /&gt;
&lt;br /&gt;
First, create a json file called config.json in the App/Config directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
	{&lt;br /&gt;
	&amp;quot;database&amp;quot;:{&amp;quot;driver&amp;quot;:&amp;quot;mysql&amp;quot;,&amp;quot;host&amp;quot;:&amp;quot;localhost&amp;quot;,&amp;quot;user&amp;quot;:&amp;quot;root&amp;quot;,&amp;quot;password&amp;quot;:&amp;quot;root&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;mydatabase&amp;quot;,&amp;quot;prefix&amp;quot;:&amp;quot;app_&amp;quot;},&lt;br /&gt;
	&amp;quot;system&amp;quot;:{&amp;quot;list_limit&amp;quot;:&amp;quot;20&amp;quot;,&amp;quot;gzip&amp;quot;:&amp;quot;0&amp;quot;,&amp;quot;offset&amp;quot;:&amp;quot;UTC&amp;quot;},&amp;quot;languages&amp;quot;:[&amp;quot;en-GB&amp;quot;]&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then when bootstrapping your app (maybe in the index.php) do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
	$config = json_decode(file_get_contents(JPATH_CONFIGURATION.&amp;#039;/config.json&amp;#039;),true);&lt;br /&gt;
	$application = new \App\App(null,new \Joomla\Registry\Registry($config));&lt;br /&gt;
	$application-&amp;gt;execute();&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then in the doExecute() method of your app create a reference to the database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
	$dbFactory = new Database\DatabaseFactory;&lt;br /&gt;
	$this-&amp;gt;db = $dbFactory-&amp;gt;getDriver(&lt;br /&gt;
		$this-&amp;gt;get(&amp;#039;database.driver&amp;#039;),&lt;br /&gt;
		array(&lt;br /&gt;
			&amp;#039;host&amp;#039;=&amp;gt;$this-&amp;gt;get(&amp;#039;database.host&amp;#039;),&lt;br /&gt;
			&amp;#039;user&amp;#039;=&amp;gt;$this-&amp;gt;get(&amp;#039;database.user&amp;#039;),&lt;br /&gt;
			&amp;#039;password&amp;#039;=&amp;gt;$this-&amp;gt;get(&amp;#039;database.password&amp;#039;),&lt;br /&gt;
			&amp;#039;port&amp;#039;=&amp;gt;$this-&amp;gt;get(&amp;#039;database.port&amp;#039;),&lt;br /&gt;
			&amp;#039;socket&amp;#039;=&amp;gt;$this-&amp;gt;get(&amp;#039;database.socket&amp;#039;),&lt;br /&gt;
			&amp;#039;database&amp;#039;=&amp;gt;$this-&amp;gt;get(&amp;#039;database.name&amp;#039;),&lt;br /&gt;
			)&lt;br /&gt;
		);&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your controller the database can then be accessed using:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
	$app = $this-&amp;gt;getApplication();&lt;br /&gt;
	$db = $app-&amp;gt;db;&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Purplebeanie</name></author>
	</entry>
</feed>