Skip to content

Commit

Permalink
add README and text to homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
Spomky committed Mar 1, 2024
1 parent a3f57e3 commit 2b08e8c
Show file tree
Hide file tree
Showing 29 changed files with 1,354 additions and 61 deletions.
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ APP_SECRET=0aabd8ac1e1554db5b50ca9d54ad796c
# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
DATABASE_URL="postgresql://app:[email protected]:5432/app?serverVersion=16&charset=utf8"
###< doctrine/doctrine-bundle ###

###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$'
###< nelmio/cors-bundle ###
File renamed without changes.
3 changes: 3 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
web: vendor/bin/heroku-php-nginx -C nginx.conf -F fpm_custom.conf public/
# release: bin/console tailwind:build && bin/console importmap:install && bin/console asset-map:compile

8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This application is a PWA (Progressive Web Application) built with Symfony and PHPWA.

## Getting Started
## Getting Started (Docker)


### With Docker
Expand All @@ -28,6 +28,12 @@ This application is a PWA (Progressive Web Application) built with Symfony and P
8. Open `https://localhost:8000` in your favorite web browser
9. Run `symfony server:stop` to stop the server

## Getting Started

Install Symfony CLI and PostgreSQL

bin/console d:d:c

## License

It is available under the MIT License.
35 changes: 35 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "phpwa-demo",
"description": "A repo, maybe get this from github",
"keywords": [
"php",
"symfony"
],
"repository": "https:\/\/github.com\/survos-sites\/phpwa-demo",
"scripts": {
"dokku": {
"predeploy": "bin/console tailwind:build && bin\/console importmap:install && bin\/console asset-map:compile",
"postdeploy": ""
}
},
"env": {
"SECRET_TOKEN": {
"description": "A secret key for verifying the integrity of signed cookies.",
"value": "secret"
},
"WEB_CONCURRENCY": {
"description": "The number of processes to run.",
"generator": "echo 5"
}
},
"image": "gliderlabs\/herokuish",
"addons": [
"dokku-postgres",
"dokku-redis"
],
"buildpacks": [
{
"url": "https:\/\/github.com\/heroku\/heroku-buildpack-php.git"
}
]
}
3 changes: 2 additions & 1 deletion assets/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { startStimulusApp } from '@symfony/stimulus-bundle';
import Timeago from 'stimulus-timeago'

const app = startStimulusApp();
// register any custom, 3rd party controllers here
// app.register('some_controller_name', SomeImportedController);
app.register('timeago', Timeago);
2 changes: 1 addition & 1 deletion assets/controllers/hello_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ import { Controller } from '@hotwired/stimulus';
*/
export default class extends Controller {
connect() {
this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js';
this.element.textContent = 'Hello, welcome to phpwa-demo!';
}
}
56 changes: 56 additions & 0 deletions assets/controllers/items_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Controller } from '@hotwired/stimulus';

/*
* The following line makes this controller "lazy": it won't be downloaded until needed
* See https://github.com/symfony/stimulus-bridge#lazy-controllers
*/
/* stimulusFetch: 'lazy' */
export default class extends Controller {
static targets = ['list', 'message']
static values = {
collectionUrl: String,
}
// ...
connect() {
this.messageTarget.innerHTML = 'fetching ' + this.collectionUrlValue;
this.loadList();
}


async loadList() {
try {
// this endpoint will return CORS error
const response = await fetch(this.collectionUrlValue);
if (!response.ok) {
throw new Error("Network response was not OK");
this.errorTarget.innerHTML = 'unable to fetch items at this time.';
console.error('Failed');
return;
} else {
// promise resolved.
const items = await response.json();
const count = items['hydra:totalItems'];
this.messageTarget.innerHTML = `${count} total items`;

this.listTarget.innerHTML = '<ol>'
for (const item of items['hydra:member']) {
// this.listTarget.innerHTML += `<li>${item.name}</li>`;
console.log(item);
}
this.listTarget.innerHTML += `</ol>`;

console.log(items);

}
} catch {
this.messageTarget.innerHTML = 'unable to fetch items at this time.';
console.error('Failed');
return;
}
}

refresh() {
this.loadList();
}

}
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@
"ext-ctype": "*",
"ext-iconv": "*",
"ext-imagick": "*",
"api-platform/core": "^3.2",
"doctrine/dbal": "^3",
"doctrine/doctrine-bundle": "^2.11",
"doctrine/doctrine-migrations-bundle": "^3.3",
"doctrine/orm": "^3.0",
"knplabs/knp-time-bundle": "^2.2",
"nelmio/cors-bundle": "^2.4",
"phpdocumentor/reflection-docblock": "^5.3",
"phpstan/phpdoc-parser": "^1.25",
"spomky-labs/phpwa": "^1.0",
"survos/deployment-bundle": "^1.5",
"symfony/asset": "7.0.*",
"symfony/asset-mapper": "7.0.*",
"symfony/asset-mapper": "7.0.3",
"symfony/clock": "7.0.*",
"symfony/console": "7.0.*",
"symfony/dotenv": "7.0.*",
Expand All @@ -35,6 +38,7 @@
"symfony/property-access": "7.0.*",
"symfony/property-info": "7.0.*",
"symfony/runtime": "7.0.*",
"symfony/security-bundle": "7.0.*",
"symfony/serializer": "7.0.*",
"symfony/stimulus-bundle": "^2.13",
"symfony/string": "7.0.*",
Expand Down
Loading

0 comments on commit 2b08e8c

Please sign in to comment.