Quickstart n2n
The Quickstart gives you a quick introduction to the n2n framework. It assumes that you already have a first overview of the structure and setup of n2n. We recommend that you install the n2n Quickstart Composer project.
Prerequisites
n2n is fully object-oriented. Knowledge of OO programming and the Model-View-Controller (MVC) concept is therefore an advantage. But if you are not yet familiar with this world, n2n can be the perfect opportunity to get to know and appreciate the advantages of OO programming! The Quickstart will help you with this.
Install the Quickstart Project
For this Quickstart we have created a Composer project. Run the following command in a directory of your web server:
composer create-project n2n/n2n-quickstart-skeleton quickstart
Set Up the Database Connection
The Quickstart module requires database access. The database connection must be defined correctly in var/etc/app.ini. Here is an example for a local MySQL database named example, with the user root and an empty password:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; database settings for debug mode ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[database : development]
default.dsn_uri = "mysql:server=localhost;dbname=example"
default.user = "root"
default.password = ""
default.transaction_isolation_level = "SERIALIZABLE"
default.dialect = "n2n\impl\persistence\meta\mysql\MysqlDialect"
Check the Configuration
n2n knows a page.name and an application.name. page.name is the official name of your website or application, while the application.name is the internal name. Make sure that you do not use spaces or special characters in application.name. Furthermore the application.name must be unique.
[general]
page.name = "New awesome project"
application.name = "newAwesomeProject"
Attention
If you have two applications with the same
application.name, it can happen that you log in to the backend of one website and are then automatically logged in to the backend of the other website as well.
Under [locales] you can enter the default language of your application at default.
[locales]
default = "en"
"de" is also possible here. For other locales translations are still missing. n2n knows many more settings for locales. But we will not go into these at the moment.
Preparation: Create a Module
For all shown code examples we use our own module. First we have to determine a directory name (namespace) for our module. Our module should be called Quickstart. For simplicity we decide on the namespace qs. To create the module you have to create the following three directories:
app/qsvar/etc/qspublic/assets/qs
This way you have created your first n2n module! Now you are ready for the n2n Quickstart!