Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danpoynor/basic-twig-template-views-demo
Demo using Twig templating engine to create a simple PHP website skeleton
https://github.com/danpoynor/basic-twig-template-views-demo
composer demo php template-engine twig
Last synced: 28 days ago
JSON representation
Demo using Twig templating engine to create a simple PHP website skeleton
- Host: GitHub
- URL: https://github.com/danpoynor/basic-twig-template-views-demo
- Owner: danpoynor
- Created: 2024-03-28T15:32:40.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-11-06T21:17:12.000Z (3 months ago)
- Last Synced: 2024-11-16T09:17:23.382Z (3 months ago)
- Topics: composer, demo, php, template-engine, twig
- Language: Twig
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Basic Twig Template Views Demo
This demo uses the Twig templating engine to create a simple PHP website skeleton
## Tech stack
* [PHP](https://www.php.net/): A popular general-purpose scripting language that is especially suited to web development
* [Composer](https://getcomposer.org/): A Dependency Manager for PHP
* [Twig](https://twig.symfony.com/doc/3.x/): Template engine for PHP## Installation
Make sure PHP and Composer are installed:
Then clone this repo to your local hard drive. For example:
```sh
gh repo clone danpoynor/basic-twig-template-views-demo
```or
```sh
git clone https://github.com/danpoynor/basic-twig-template-views-demo.git
```Then `cd` into the project directory and run:
```sh
composer install
```This will install the Twig templating engine and other dependencies.
## Usage
Use [MAMP](https://www.mamp.info/en/mamp) or other server to run the code in your browser. Be sure to use the `public` directory as the document root (where the `index.php` file is). Start the server and view the app at the url such as .
## Developer Notes on How This Project Was Initially Created
1. Ensure PHP and Composer are installed.
2. Create a new directory for your app and `cd` into it.
3. Then run the following command to get the latest version of Twig:```sh
composer require "twig/twig:^3.0"
```This will create the initial project structure:
```sh
├── composer.json
├── composer.lock
└── vendor
├── autoload.php
├── composer/
├── symfony/
└── twig/
```3. Open your IDE in the current directory with something like `code .`.
4. Create a `public` folder with an `index.php` file inside it.
5. Copy the [Basic API Usage](https://twig.symfony.com/doc/3.x/api.html) code from the documentation, or use something like this in the `index.php` file:```php
'Hello {{ name }}!',
));
$twig = new Twig_Environment($loader);echo $twig->render('index', array('name' => 'Fabien'));
```Then follow the [Usage](#usage) notes above to preview the page and start developing.
Check code comments for additional notes.