1. Go to this page and download the library: Download flow4ui/flow-symfony library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
flow4ui / flow-symfony example snippets
namespace App\UI\Component\Todo;
use Flow\Attributes\{Action,Attribute,Component,Property};
use Flow\Component\AbstractComponent;
use Flow\Contract\HasInitState;
use Symfony\Component\HttpFoundation\Request;
#[Component(
props: [
'initialTodos'
],
template: <<<'VUE'
<template>
<div>
<ul>
<li v-for="todo in todos" :key="todo.id">
{{ todo.text }}
<button @click="removeTodo(todo.id)">Remove</button>
</li>
</ul>
<input v-model="newTodo" @keyup.enter="addTodo">
<button @click="addTodo">Add Todo</button>
</div>
</template>
VUE
)]
class TodoList extends AbstractComponent implements HasInitState
{
#[Property]
public array $todos = [];
#[Property]
public string $newTodo = '';
#[Attribute]
public array $initialTodos = null;
public function initState(Request $request): void
{
$this->todos = $this->initialTodos ?? [];
}
#[Action]
public function addTodo(): void
{
if (!empty($this->newTodo)) {
$this->todos[] = [
'id' => uniqid(),
'text' => $this->newTodo
];
$this->newTodo = '';
}
}
#[Action]
public function removeTodo(string $id): void
{
$this->todos = array_filter($this->todos, fn($todo) => $todo['id'] !== $id);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.