Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 148 Revision 991
Zeile 1... Zeile 1...
1
What is Smarty?
1
# Getting started
2
==============
-
 
Zeile 3... Zeile 2...
3
 
2
 
4
## Requirements
3
## Requirements
Zeile 5... Zeile 4...
5
Smarty can be run with PHP 7.1 to PHP 8.2.
4
Smarty can be run with PHP 7.1 to PHP 8.2.
6
 
5
 
Zeile 7... Zeile 6...
7
## Installation
6
## Installation
8
Smarty versions 3.1.11 or later can be installed with [Composer](https://getcomposer.org/).
7
Smarty can be installed with [Composer](https://getcomposer.org/).
9
 
8
 
10
To get the latest stable version of Smarty use:
9
To get the latest stable version of Smarty use:
Zeile 11... Zeile 10...
11
```bash
10
```shell
12
composer require smarty/smarty
11
composer require smarty/smarty
13
````
12
```
14
 
13
 
Zeile 15... Zeile 14...
15
To get the latest, unreleased version, use:
14
To get the latest, unreleased version, use:
16
```bash
15
```shell
17
composer require smarty/smarty:dev-master
16
composer require smarty/smarty:dev-master
18
````
17
```
Zeile 19... Zeile 18...
19
 
18
 
20
To get the previous stable version of Smarty, Smarty 3, use:
19
To get the previous stable version of Smarty, Smarty 3, use:
21
```bash
20
```shell
Zeile 22... Zeile 21...
22
composer require smarty/smarty:^3
21
composer require smarty/smarty:^3
23
````
22
```
24
 
23
 
Zeile 25... Zeile 24...
25
Here's how you create an instance of Smarty in your PHP scripts:
24
Here's how you create an instance of Smarty in your PHP scripts:
26
```php
25
```php
Zeile 27... Zeile 26...
27
<?php
26
<?php
28
 
27
 
29
require 'vendor/autoload.php';
28
require 'vendor/autoload.php';
Zeile 80... Zeile 79...
80
```
79
```
Zeile 81... Zeile 80...
81
 
80
 
82
Now, let's create the `index.tpl` file that Smarty will display. This
81
Now, let's create the `index.tpl` file that Smarty will display. This
Zeile 83... Zeile 82...
83
needs to be located in the [`$template_dir`](./programmers/api-variables/variable-template-dir.md).
82
needs to be located in the [`$template_dir`](./programmers/api-variables/variable-template-dir.md).
84
 
83
 
85
```html
84
```smarty
86
{* Smarty *}
85
{* Smarty *}
Zeile 87... Zeile 86...
87
Hello {$name}, welcome to Smarty!
86
Hello {$name}, welcome to Smarty!
Zeile 116... Zeile 115...
116
 
115
 
Zeile 117... Zeile 116...
117
```
116
```
118
 
117
 
119
> **Note**
118
> **Note**
120
>
119
>
121
> In our example, we are setting absolute paths to all of the Smarty
120
> In our example, we are setting absolute paths to all the Smarty
122
> directories. If `/web/www.example.com/guestbook/` is within your PHP
121
> directories. If `/web/www.example.com/guestbook/` is within your PHP
123
> include\_path, then these settings are not necessary. However, it is
122
> include\_path, then these settings are not necessary. However, it is
124
> more efficient and (from experience) less error-prone to set them to
123
> more efficient and (from experience) less error-prone to set them to
Zeile 125... Zeile 124...
125
> absolute paths. This ensures that Smarty is getting files from the
124
> absolute paths. This ensures that Smarty is getting files from the
Zeile 126... Zeile 125...
126
> directories you intended.
125
> directories you intended.
Zeile 127... Zeile 126...
127
 
126
 
128
Now, run your PHP file. You should see *\"Hello Ned, welcome to Smarty!\"*
-
 
Zeile 129... Zeile -...
129
 
-
 
130
You have completed the basic setup for Smarty!
127
Now, run your PHP file. You should see *"Hello Ned, welcome to Smarty!"*
Zeile 131... Zeile 128...
131
 
128
 
132
## Extended Setup {#installing.smarty.extended}
129
You have completed the basic setup for Smarty!
133
==============
130
 
134
 
131
## Extended Setup
Zeile 135... Zeile 132...
135
This is a continuation of the [basic
132
 
Zeile 161... Zeile 158...
161
}
158
}
162
```
159
```
Zeile 163... Zeile 160...
163
 
160
 
164
Now, we can use `Smarty_GuestBook` instead of `Smarty` in our scripts:
161
Now, we can use `Smarty_GuestBook` instead of `Smarty` in our scripts:
-
 
162
```php
165
```php
163
<?php
166
$smarty = new Smarty_GuestBook();
164
$smarty = new Smarty_GuestBook();
167
$smarty->assign('name','Ned');
165
$smarty->assign('name', 'Ned');
168
$smarty->display('index.tpl');
166
$smarty->display('index.tpl');