Skip to content

Commit

Permalink
feat: add webpack, with bootstrap example, slight restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
markhughes committed Apr 19, 2021
1 parent 9db6ae4 commit 5b6e714
Show file tree
Hide file tree
Showing 21 changed files with 10,022 additions and 786 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
public/resources/compiled
var/cache
var/logs
dist/
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Flight Skeleton
This skeleton provides a quick start for the development of an application with the [Flight](http://flightphp.com) PHP microframework.

It also adds support for Sass, Twig, and even TypeScript!

## Downloading the skeleton
First, check that you have installed and configured a web server (such as Nginx) with PHP 8 or higher. Then use git to clone this repo:

Expand All @@ -10,12 +12,12 @@ First, check that you have installed and configured a web server (such as Nginx)
If you want to define global constants or other settings, you can use the `config.php` in `app/config/`.

### Routing
To define your routes, use the file `app/config/routes`:
To define your routes, use the file `app/config/routes.php`:

```php
<?php

Flight::route("/", array("\Acme\Demo\Controller\Demo", "index"));
Flight::route("/", ["\Acme\Demo\Controller\Demo", "index"]);
```

### Controllers
Expand All @@ -24,5 +26,12 @@ Place your code in the `src` folder. All classes from here are autoloaded by the
### Templates
Twig templates are loaded by default from `app/resouces/views/`. You can change this by editing the path in `app/config/config.php`.

### Logging
Your application logs into `var/logs`. Should you want to, you can add more loggers in `app/config/logger_handlers.php`, or completely reconfigure it in
`app/logger.php`.

### Webpack
Compile your scripts using `npm run webpack` which will throw it all together in `public/dist/main.js` - check the webpack docs on how to use it more effectively. Your entrypoint is located in `app/resources/scripts/index.ts` if you don't want to use TypeScript just rename index.ts to index.js.

# License
The skeleton is licensed under the [MIT](http://www.opensource.org/licenses/mit-license.php) license.
The skeleton is licensed under the [MIT](https://opensource.org/licenses/MIT) license.
2 changes: 2 additions & 0 deletions app/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
define("APP_NAME", "my_app");
define("DEBUG", true);

//... add more here for your app!

// -------------------------------------------------- //
// FLIGHT CONFIG
// -------------------------------------------------- //
Expand Down
2 changes: 1 addition & 1 deletion app/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@

Flight::map("notFound", fn() => Flight::render("404", []));

Flight::map("error", fn(Exception $exception) => $logger->error($exception));
Flight::map("error", fn(Throwable $exception) => $logger->error($exception));
8 changes: 8 additions & 0 deletions app/logger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

// Setup logger
$logger = new \Monolog\Logger(APP_NAME);

foreach (create_log_handlers() as $logHandler) {
$logger->pushHandler($logHandler);
}
5 changes: 5 additions & 0 deletions app/resources/scripts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Hello! If you don't want typescript, just rename this file to index.js.
require('bootstrap');
require('../scss/main.scss')

console.log('hello world!')
3 changes: 1 addition & 2 deletions app/resources/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
@import "partials/base";

// Vendor sheets
@import "vendor/html5boilerplate";
@import "vendor/normalize";
@import "vendor/bootstrap";

// Partials
@import "partials/hello"
1 change: 1 addition & 0 deletions app/resources/scss/vendor/_bootstrap.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "~bootstrap/scss/bootstrap";
297 changes: 0 additions & 297 deletions app/resources/scss/vendor/_html5boilerplate.scss

This file was deleted.

Loading

0 comments on commit 5b6e714

Please sign in to comment.