layout | title | order |
---|---|---|
page |
Quick Start |
2 |
- Docker
- docker-compose
- Composer
- PHP ^7.1
composer create-project wtf/skeleton your-app
This command creates the skeleton project with structure, shown below:
your-app
├── app # Main app dir
│ ├── cache # Cache dir
│ ├── config # Config dir
│ ├── migrations # DB migrations dir
│ ├── public # Public dir accessible from internet
│ ├── seeds # DB seeds dir
│ ├── src # App source code
│ │ ├── Controller # Controllers
│ │ ├── Controller.php # Main app controller
│ │ ├── Entity # Entities
│ │ ├── ErrorHandler.php # App error handler
│ │ ├── Middleware # App middlewares
│ │ └── Provider.php # App service provider
│ ├── tests # App tests
│ └── vendor # 3rdParty dependencies
├── composer.json # package manager configuration
├── Dockerfile # Docker configuration
├── .dockerignore # List of ignored files in docker
├── env # Docker environments
│ ├── dev.yml # Development, default
│ ├── prod.yml # Production
│ └── qa.yml # QA/Staging
├── .env # docker-compose env
├── .gitignore # List of ignored files in git
├── .gitlab-ci.yml # Gitlab CI/CD configuration
├── .php_cs.dist # php-cs-fixer configuration
├── phpunit.xml.dist # PHPUnit configuration
└── README.md # README
Generate your first CRUD called App
:
app/vendor/bin/wtf generate:crud App -c app/config/generator.php
You should see something like this in output:
WTF framework generator
Controller saved to ./app/src/Controller/App.php
Test saved to ./app/tests/App.php
Entity saved to ./app/src/Entity/App.php
Test saved to ./app/tests/App.php
Route saved to ./app/config/routes/app.php
Migration saved to ./app/migrations/20180406100619_init_app.php
Now, let's add What the fuck? It works!
text in your controller:
- Open
app/src/Controller/App.php
- Replace entire content in function
indexAction()
withreturn $this->json(['What the fuck?' => 'It works!']);
public function indexAction(): ResponseInterface
{
return $this->json(['What the fuck?' => 'It works!']);
}
And let's test it:
docker-compose up -d
curl http://localhost:8080/app
The result will be:
{"error":{"message":null,"fields":[]},"count":1,"data":{"What the fuck?":"It works!"}}
That's all, folks!
{% assign pages = site.pages | sort: 'order' %} {% for item in pages %} {%- if item.title and item.title != "404 - Page not found" and item.title != page.title -%} <[{{ item.title }}]({{ item.url}})> {%- endif -%} {% endfor %}<[API docs]({{ site.baseurl }}/api)>