Se non si dispone di un server web, è possibile crearne uno, con WebMatrix.
WebMatrix
WebMatrix è uno strumento di sviluppo web gratuito che fornisce un modo semplice per costruire siti web.
WebMatrix contiene:
- esempi e modelli Web
- Supporto per diversi linguaggi web (PHP, ASP.NET, Node.js)
- Un server web
- Server di database (mySQL and SQL Server Compact)
Con WebMatrix si può iniziare con un sito web vuota, o costruire su modelli esistenti che utilizzano PHP, ASP, Umbraco, DotNetNuke, Drupal, Joomla, WordPress e molto altro ancora.
WebMatrix ha anche strumenti integrati per banche dati, la sicurezza, l'ottimizzazione dei motori di ricerca, e web publishing.
Per installare WebMatrix, segui questo link: http://www.microsoft.com/web/webmatrix
Crea un vuoto PHP Site
In WebMatrix, selezionare galleria di modelli. Selezionare PHP. Selezionare Vuoto sito.
Modificare il nome del sito a DemoAppml (or anything you like) , e fare clic su Avanti.
Come si può vedere dalla figura, WebMatrix vi permetterà di creare diversi tipi di siti web.
Creare una pagina di prova HTML
Nella finestra WebMatrix, selezionare Nuovo. Selezionare Nuovo file. Selezionare il tipo di file HTML.
Cambiare il nome del file per Customers.htm (or anything you like) . Fare clic su OK.
Sostituire il codice HTML nel nuovo file con questo:
Customers.htm
<!DOCTYPE html>
<html lang="en">
<title>Customers</title>
<link rel="stylesheet" href=
"http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="http://www.w3ii.com/appml/2.0.3/appml.js"></script>
<body>
<div class="container" appml-data="customers">
<h1>Customers</h1>
<table class="table table-striped table-bordered">
<tr>
<th>Customer</th>
<th>City</th>
<th>Country</th>
</tr>
<tr appml-repeat="records">
<td>{{CustomerName}}</td>
<td>{{City}} </td>
<td>{{Country}} </td>
</tr>
</table>
</div>
<script>
var customers = {
"records":[
{"CustomerName":"Alfreds Futterkiste","City":"Berlin","Country":"Germany"},
{"CustomerName":"Ana Trujillo Emparedados y helados","City":"Mexico D.F.","Country":"Mexico"},
{"CustomerName":"Antonio Moreno Taqueria","City":"Mexico D.F.","Country":"Mexico"},
{"CustomerName":"Around the Horn","City":"London","Country":"UK"},
{"CustomerName":"B's
Beverages","City":"London","Country":"UK"},
{"CustomerName":"Berglunds
snabbkop","City":"Lulea","Country":"Sweden"},
{"CustomerName":"Blauer See
Delikatessen","City":"Mannheim","Country":"Germany"},
{"CustomerName":"Blondel
pere et fils","City":"Strasbourg","Country":"France"},
{"CustomerName":"Bolido
Comidas preparadas","City":"Madrid","Country":"Spain"},
{"CustomerName":"Bon
app'","City":"Marseille","Country":"France"},
{"CustomerName":"Bottom-Dollar
Marketse","City":"Tsawassen","Country":"Canada"},
{"CustomerName":"Cactus
Comidas para llevar","City":"Buenos Aires","Country":"Argentina"},
{"CustomerName":"Centro
comercial Moctezuma","City":"Mexico D.F.","Country":"Mexico"},
{"CustomerName":"Chop-suey Chinese","City":"Bern","Country":"Switzerland"},
{"CustomerName":"Comercio Mineiro","City":"Sao Paulo","Country":"Brazil"}
]};
</script>
</body>
</html>
Prova tu stesso " Per eseguire la pagina di prova: Fare clic sulla pagina in WebMatrix, e selezionare Avvia in browser.
Creazione di un database
Nella finestra WebMatrix selezionare Database. Selezionare Nuovo database. Selezionare Database MySQL.
Cambiare il nome del database per DemoDB (or anything you like) , e fare clic su OK.
In WebMatrix, selezionare i file e aprire il file web.config.
(Se non è possibile vedere il file web.config, aggiornare WebMatrix)
Configurare AppML
Utilizzare le informazioni, dalla stringa di connessione nel web.config, per creare un file di configurazione per AppML.
Nome del file appml_config.php:
appml_config.php
<?php echo("Access Forbidden");exit();?>
{
"dateformat" : "yyyy-mm-dd",
"databases" : [{
"connection" : "mydatabase",
"host" : "localhost",
"dbname" : "DemoDB",
"username" : "DemoDBUkbn5",
"password" : "l6|U6=V(*T+P"
}]
}
File di configurazione spiegato:
Proprietà | Descrizione |
---|---|
dateformat | Il formato della data che si intende utilizzare nei tuoi modelli |
connection | Il nome della connessione che si utilizza nei tuoi modelli |
host | Il nome host IP o si trovano in server = |
dbname | Il nome del database trovato nel database = |
username | Il nome utente trovato in = uid |
password | La password trovata in pwd = |
Copia AppML
Scaricare il file: http://www.w3ii.com/appml/2.0.3/appml.php.txt .
Copiare il file al tuo sito web. Rinominarlo in appml.php:
Creare una tabella di database
Creare un modello per la creazione di una tabella Clienti nel database.
Create_Customers.js
{
"database" : {
"connection" : "mydatabase",
"execute" : [
"DROP
TABLE IF EXISTS Customers",
"CREATE TABLE IF NOT EXISTS Customers (CustomerID
INT NOT NULL AUTO_INCREMENT,PRIMARY KEY (CustomerID),CustomerName NVARCHAR(255),ContactName
NVARCHAR(255),Address NVARCHAR(255),City NVARCHAR(255),PostalCode NVARCHAR(255),Country
NVARCHAR(255))",
"INSERT INTO Customers(CustomerName,ContactName,Address,City,PostalCode,Country)VALUES (\"Alfreds Futterkiste\",\"Maria Anders\",\"Obere Str.
57\",\"Berlin\",\"12209\",\"Germany\")",
"INSERT INTO Customers(CustomerName,ContactName,Address,City,PostalCode,Country)VALUES (\"Around the Horn\",\"Thomas Hardy\",\"120 Hanover
Sq.\",\"London\",\"WA1 1DP\",\"UK\")",
"INSERT INTO Customers(CustomerName,ContactName,Address,City,PostalCode,Country)VALUES (\"Blauer See Delikatessen\",\"Hanna Moos\",\"Forsterstr.
57\",\"Mannheim\",\"68306\",\"Germany\")"
]
}}
Creare una pagina HTML per l'esecuzione del modello Create_Customers:
Create_Customers.htm
<!DOCTYPE html>
<html lang="en-US">
<script src="http://www.w3ii.com/appml/2.0.3/appml.js"></script>
<body>
<div appml-data="appml.php?model=Create_Customers"></div>
</body>
</html>
Per eseguire la pagina HTML: Fare clic sulla pagina in WebMatrix, e selezionare Avvia in browser.
Creare un'applicazione
Creare un modello per l'applicazione ai clienti. Salvarlo come customers.js:
Customers.js
{
"rowsperpage" : 10,
"database" : {
"connection" : "mydatabase",
"sql" : "SELECT * FROM Customers",
"orderby" : "CustomerName"
}
}
Creare una pagina HTML per eseguire l'applicazione ai clienti:
Customers.htm
<!DOCTYPE html>
<html lang="en">
<title>Customers</title>
<link rel="stylesheet" href=
"http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="http://www.w3ii.com/appml/2.0.3/appml.js"></script>
<body>
<div class="container" appml-data="appml.php?model=customers">
<h1>Customers</h1>
<table class="table table-striped table-bordered">
<tr>
<th>Customer</th>
<th>City</th>
<th>Country</th>
</tr>
<tr appml-repeat="records">
<td>{{CustomerName}}</td>
<td>{{City}}</td>
<td>{{Country}}</td>
</tr>
</table>
</div>
</body>
</html>
Prova tu stesso " Per eseguire la pagina HTML: Fare clic sulla pagina in WebMatrix, e selezionare Avvia in browser.