143 |
144 | [Source on GitHub](https://github.com/phalcon/cphalcon/blob/{{ pageVersion }}.x/phalcon/Messages/MessageInterface.zep)
145 |
146 | | Namespace | Phalcon\Messages |
147 |
148 | Phalcon\Messages\MessageInterface
149 |
150 | Interface for Phalcon\Messages\MessageInterface
151 |
152 |
153 | ## Methods
154 |
155 | ```php
156 | public function __toString(): string;
157 | ```
158 | Magic __toString method returns verbose message
159 |
160 |
161 | ```php
162 | public function getCode();
163 | ```
164 | Returns the message code related to this message
165 |
166 |
167 | ```php
168 | public function getField();
169 | ```
170 | Returns field name related to message
171 |
172 |
173 | ```php
174 | public function getMessage(): string;
175 | ```
176 | Returns verbose message
177 |
178 |
179 | ```php
180 | public function getMetaData(): array;
181 | ```
182 | Returns message metadata
183 |
184 |
185 | ```php
186 | public function getType(): string;
187 | ```
188 | Returns message type
189 |
190 |
191 | ```php
192 | public function setCode( int $code ): MessageInterface;
193 | ```
194 | Sets code for the message
195 |
196 |
197 | ```php
198 | public function setField( string $field ): MessageInterface;
199 | ```
200 | Sets field name related to message
201 |
202 |
203 | ```php
204 | public function setMessage( string $message ): MessageInterface;
205 | ```
206 | Sets verbose message
207 |
208 |
209 | ```php
210 | public function setMetaData( array $metaData ): MessageInterface;
211 | ```
212 | Sets message metadata
213 |
214 |
215 | ```php
216 | public function setType( string $type ): MessageInterface;
217 | ```
218 | Sets message type
219 |
220 |
221 |
222 |
223 |
Class Phalcon\Messages\Messages
224 |
225 | [Source on GitHub](https://github.com/phalcon/cphalcon/blob/{{ pageVersion }}.x/phalcon/Messages/Messages.zep)
226 |
227 | | Namespace | Phalcon\Messages |
228 | | Uses | ArrayAccess, Countable, Iterator, JsonSerializable |
229 | | Implements | ArrayAccess, Countable, Iterator, JsonSerializable |
230 |
231 | Represents a collection of messages
232 |
233 |
234 | ## Properties
235 | ```php
236 | /**
237 | * @var int
238 | */
239 | protected position = 0;
240 |
241 | /**
242 | * @var array
243 | */
244 | protected messages;
245 |
246 | ```
247 |
248 | ## Methods
249 |
250 | ```php
251 | public function __construct( array $messages = [] );
252 | ```
253 | Phalcon\Messages\Messages constructor
254 |
255 |
256 | ```php
257 | public function appendMessage( MessageInterface $message );
258 | ```
259 | Appends a message to the collection
260 |
261 | ```php
262 | $messages->appendMessage(
263 | new \Phalcon\Messages\Message("This is a message")
264 | );
265 | ```
266 |
267 |
268 | ```php
269 | public function appendMessages( mixed $messages );
270 | ```
271 | Appends an array of messages to the collection
272 |
273 | ```php
274 | $messages->appendMessages($messagesArray);
275 | ```
276 |
277 |
278 | ```php
279 | public function count(): int;
280 | ```
281 | Returns the number of messages in the list
282 |
283 |
284 | ```php
285 | public function current(): MessageInterface;
286 | ```
287 | Returns the current message in the iterator
288 |
289 |
290 | ```php
291 | public function filter( string $fieldName ): array;
292 | ```
293 | Filters the message collection by field name
294 |
295 |
296 | ```php
297 | public function jsonSerialize(): array;
298 | ```
299 | Returns serialised message objects as array for json_encode. Calls
300 | jsonSerialize on each object if present
301 |
302 | ```php
303 | $data = $messages->jsonSerialize();
304 | echo json_encode($data);
305 | ```
306 |
307 |
308 | ```php
309 | public function key(): int;
310 | ```
311 | Returns the current position/key in the iterator
312 |
313 |
314 | ```php
315 | public function next(): void;
316 | ```
317 | Moves the internal iteration pointer to the next position
318 |
319 |
320 | ```php
321 | public function offsetExists( mixed $index ): bool;
322 | ```
323 | Checks if an index exists
324 |
325 | ```php
326 | var_dump(
327 | isset($message["database"])
328 | );
329 | ```
330 |
331 |
332 | ```php
333 | public function offsetGet( mixed $index ): mixed;
334 | ```
335 | Gets an attribute a message using the array syntax
336 |
337 | ```php
338 | print_r(
339 | $messages[0]
340 | );
341 | ```
342 |
343 |
344 | ```php
345 | public function offsetSet( mixed $index, mixed $message ): void;
346 | ```
347 | Sets an attribute using the array-syntax
348 |
349 | ```php
350 | $messages[0] = new \Phalcon\Messages\Message("This is a message");
351 | ```
352 |
353 |
354 | ```php
355 | public function offsetUnset( mixed $index ): void;
356 | ```
357 | Removes a message from the list
358 |
359 | ```php
360 | unset($message["database"]);
361 | ```
362 |
363 |
364 | ```php
365 | public function rewind(): void;
366 | ```
367 | Rewinds the internal iterator
368 |
369 |
370 | ```php
371 | public function valid(): bool;
372 | ```
373 | Check if the current message in the iterator is valid
374 |
--------------------------------------------------------------------------------
/docs/assets/images/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/apple-touch-icon.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-linux-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-linux-1.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-linux-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-linux-2.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-mac-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-mac-1.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-mac-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-mac-2.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-usage-01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-usage-01.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-usage-02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-usage-02.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-usage-03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-usage-03.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-usage-04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-usage-04.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-usage-05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-usage-05.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-usage-11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-usage-11.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-windows-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-windows-1.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-windows-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-windows-2.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-windows-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-windows-3.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-windows-4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-windows-4.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-windows-5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-windows-5.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-windows-6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-windows-6.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-windows-7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-windows-7.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-windows-8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-windows-8.png
--------------------------------------------------------------------------------
/docs/assets/images/content/devtools-windows-9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/devtools-windows-9.png
--------------------------------------------------------------------------------
/docs/assets/images/content/filter-sql.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/filter-sql.png
--------------------------------------------------------------------------------
/docs/assets/images/content/models-relationships-erd-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/models-relationships-erd-1.png
--------------------------------------------------------------------------------
/docs/assets/images/content/performance-chrome-1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/performance-chrome-1.jpg
--------------------------------------------------------------------------------
/docs/assets/images/content/performance-firefox-1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/performance-firefox-1.jpg
--------------------------------------------------------------------------------
/docs/assets/images/content/performance-speed-tracer.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/performance-speed-tracer.jpg
--------------------------------------------------------------------------------
/docs/assets/images/content/performance-xhprof-1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/performance-xhprof-1.jpg
--------------------------------------------------------------------------------
/docs/assets/images/content/performance-xhprof-2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/performance-xhprof-2.jpg
--------------------------------------------------------------------------------
/docs/assets/images/content/performance-yslow-1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/performance-yslow-1.jpg
--------------------------------------------------------------------------------
/docs/assets/images/content/phpinfo-api.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/phpinfo-api.png
--------------------------------------------------------------------------------
/docs/assets/images/content/tutorial-basic-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/tutorial-basic-1.png
--------------------------------------------------------------------------------
/docs/assets/images/content/tutorial-basic-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/tutorial-basic-2.png
--------------------------------------------------------------------------------
/docs/assets/images/content/tutorial-basic-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/tutorial-basic-3.png
--------------------------------------------------------------------------------
/docs/assets/images/content/tutorial-basic-4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/tutorial-basic-4.png
--------------------------------------------------------------------------------
/docs/assets/images/content/tutorial-basic-5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/tutorial-basic-5.png
--------------------------------------------------------------------------------
/docs/assets/images/content/tutorial-basic-6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/tutorial-basic-6.png
--------------------------------------------------------------------------------
/docs/assets/images/content/tutorial-invo-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/tutorial-invo-1.png
--------------------------------------------------------------------------------
/docs/assets/images/content/tutorial-invo-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/tutorial-invo-2.png
--------------------------------------------------------------------------------
/docs/assets/images/content/tutorial-vokuro-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/tutorial-vokuro-1.png
--------------------------------------------------------------------------------
/docs/assets/images/content/tutorial-vokuro-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/tutorial-vokuro-2.png
--------------------------------------------------------------------------------
/docs/assets/images/content/tutorial-vokuro-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/tutorial-vokuro-3.png
--------------------------------------------------------------------------------
/docs/assets/images/content/tutorial-vokuro-4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/tutorial-vokuro-4.png
--------------------------------------------------------------------------------
/docs/assets/images/content/v4/devtools-store-dirstructure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/v4/devtools-store-dirstructure.png
--------------------------------------------------------------------------------
/docs/assets/images/content/v4/devtools-store-localhost.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/v4/devtools-store-localhost.png
--------------------------------------------------------------------------------
/docs/assets/images/content/views-layout.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/views-layout.png
--------------------------------------------------------------------------------
/docs/assets/images/content/views-volt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/views-volt.png
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-architecture.png
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-cherokee-1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-cherokee-1.jpg
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-cherokee-2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-cherokee-2.jpg
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-cherokee-3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-cherokee-3.jpg
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-cherokee-4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-cherokee-4.jpg
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-cherokee-5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-cherokee-5.jpg
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-cherokee-6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-cherokee-6.jpg
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-cherokee-7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-cherokee-7.jpg
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-cherokee-8.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-cherokee-8.jpg
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-cherokee-9.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-cherokee-9.jpg
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-extracted-dlls.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-extracted-dlls.png
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-wamp-apache-phalcon-php-ini.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-wamp-apache-phalcon-php-ini.png
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-wamp-manager.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-wamp-manager.png
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-wamp-phalcon-php-ini.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-wamp-phalcon-php-ini.png
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-wamp-phalcon-psr-ext-folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-wamp-phalcon-psr-ext-folder.png
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-wamp-phalcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-wamp-phalcon.png
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-xampp-phalcon-php-ini.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-xampp-phalcon-php-ini.png
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-xampp-phalcon-psr-ext-folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-xampp-phalcon-psr-ext-folder.png
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-xampp-phpinfo-phalcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-xampp-phpinfo-phalcon.png
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-xampp-phpinfo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-xampp-phpinfo.png
--------------------------------------------------------------------------------
/docs/assets/images/content/webserver-zip-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/webserver-zip-icon.png
--------------------------------------------------------------------------------
/docs/assets/images/content/xdebug-1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/content/xdebug-1.jpg
--------------------------------------------------------------------------------
/docs/assets/images/document-status-stable-success.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/document-status-under-review-red.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/edit_pencil.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/favicon.ico
--------------------------------------------------------------------------------
/docs/assets/images/icons/advantages-community-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/advantages-community-icon.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/advantages-community-icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/icons/advantages-developer-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/advantages-developer-icon.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/advantages-developer-icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/icons/advantages-help-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/advantages-help-icon.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/advantages-help-icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/icons/arrow-right-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/arrow-right-icon.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/arrow-right-icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/icons/divider-topic-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/divider-topic-icon.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/explore-topic-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/explore-topic-icon.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/github-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/github-icon.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/github-icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/icons/i-letter-image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/i-letter-image.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/message-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/message-icon.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/message-icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/icons/serch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/serch-icon.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/serch-icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/icons/social/discord-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/social/discord-logo.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/social/facebook-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/social/facebook-logo.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/social/gab-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/social/gab-logo.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/social/mewe-logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/social/mewe-logo.jpg
--------------------------------------------------------------------------------
/docs/assets/images/icons/social/slack-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/social/slack-logo.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/social/stack-overflow-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/social/stack-overflow-logo.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/social/twitter-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/social/twitter-logo.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/topic-categories-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/topic-categories-icon.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/topic-category-small-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/topic-category-small-icon.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/topic-category-small-icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/icons/topic-head-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/topic-head-icon.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/topic-head-icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/icons/topic-item-icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/icons/topic-message-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phalcon/documentation/d9b4f6c37502efa09c046653d9c5ccdae540f04b/docs/assets/images/icons/topic-message-icon.png
--------------------------------------------------------------------------------
/docs/assets/images/icons/topic-message-icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/implements-psr--0-blue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/implements-psr--11-blue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/implements-psr--13-blue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/implements-psr--14-blue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/implements-psr--15-blue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/implements-psr--16-blue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/implements-psr--17-blue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/implements-psr--18-blue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/implements-psr--2-blue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/implements-psr--3-blue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/implements-psr--4-blue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/implements-psr--6-blue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/implements-psr--7-blue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/level-advanced.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/level-beginner.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/level-intermediate.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/status-changes-required-red.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/status-docs.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/status-no-changes-blue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/version-3.4.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/version-4.0.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/version-4.1.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/images/version-5.0.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/coding-standard.md:
--------------------------------------------------------------------------------
1 | # Phalcon Coding Standard
2 | - - -
3 |
4 | Last update: 2019-07-04
5 |
6 | Phalcon is written in [Zephir][zephir], a language that the Phalcon Team invented and is actively developing. Therefore, there are no established coding standards that developers can follow, should they wish to.
7 |
8 | In this document we outline the coding standard that Phalcon is using for editing Zephir files. The coding standard is a variant of [PSR-12][psr-12] developed by [PHP-FIG][php-fig]
9 |
10 | ## Files
11 | * Files must use only UTF-8 without BOM.
12 | - File names must be named StudlyCaps.
13 | - All files must use the Unix LF (linefeed) line ending.
14 | - All files must end with a single blank line.
15 | - Folders are also named StudlyCaps and the folder/sub-folder tree follows the namespace of the class.
16 |
17 | ```php
18 | phalcon/Acl/Adapter/Memory.zep
19 | ```
20 |
21 | ```php
22 | namespace Phalcon\Acl\Adapter;
23 |
24 | use Phalcon\Acl\Adapter;
25 |
26 | class Memory extends Adapter
27 | {
28 |
29 | }
30 | ```
31 |
32 | - Code must use 4 spaces for indenting, not tabs.
33 | - Lines should be 80 characters or fewer. The hard limit on line length is 120 characters.
34 | - There must be one blank line after the namespace declaration, and there must be one blank line after the block of use declarations.
35 | - There must not be trailing whitespace at the end of non-blank lines.
36 | - Blank lines may be added to improve readability and to indicate related blocks of code.
37 | - There must not be more than one statement per line.
38 |
39 | ## Classes
40 | - Class names must be declared in StudlyCaps.
41 | - Opening braces for classes must go on the next line, and closing braces must go on the next line after the body.
42 | - Abstract classes must be prefixed by `Abstract`
43 | - Interfaces must be suffixed by `Interface`
44 |
45 | ### Constants
46 | - Class constants must be declared in all upper case with underscore separators.
47 | - Class constants must appear at the top of the class.
48 | - Class constants must be sorted alphabetically by constant name.
49 |
50 | ```php
51 | namespace Phalcon\Acl;
52 |
53 | class Enum
54 | {
55 | const ALLOW = 1;
56 | const DENY = 0;
57 | }
58 | ```
59 |
60 | ### Properties
61 | - Class properties must be declared in camelCase.
62 | - Class properties must be sorted alphabetically based on name.
63 | - Whenever possible, properties must have a default value.
64 | - Whenever possible, properties must have a docblock that defines their type with the `@var` declaration.
65 | - Properties must not be prefixed with underscore `_`. The only exception is if the property name is a reserved keyword such as `default`, `namespace` etc.
66 |
67 | ```php
68 | namespace Phalcon\Acl\Adapter;
69 |
70 | use Phalcon\Acl\Adapter;
71 |
72 | class Memory extends Adapter
73 | {
74 | /**
75 | * @var string | null
76 | */
77 | protected activeKey = "" { get };
78 | }
79 | ```
80 |
81 | ### Methods
82 | - Method names must be declared in camelCase.
83 | - Methods must be sorted alphabetically and based on their visibility. The order is `public`, `protected` and `private`. `__construct` if defined must be at the top of the class.
84 | - Method names must not be prefixed with underscore `_`.
85 | - All methods must have a return type. If the method does not return anything it should be marked `void`
86 | - Opening braces for methods must go on the next line, and closing braces must go on the next line after the body.
87 | - Visibility must be declared on all properties and methods; `abstract` and `final` must be declared before the visibility; `static` must be declared after the visibility.
88 |
89 | ```php
90 | abstract public function getElement() -> var;
91 |
92 | final public function getElement() -> var;
93 |
94 | public static function getElement() -> var;
95 | ```
96 |
97 | - Control structure keywords must have one space after them; method and function calls must not.
98 | - Opening braces for control structures must go on the same line, and closing braces must go on the next line after the body.
99 | - Control structures such as `if` must not have parentheses around the conditional, unless it is a complex one.
100 |
101 | ```php
102 | if typeof variable === "array" {
103 |
104 | }
105 | ```
106 |
107 | ### Method Arguments
108 | - In the argument list, there must not be a space before each comma, and there must be one space after each comma.
109 | - Each method must have its type declared before it
110 | - Method arguments with default values must go at the end of the argument list.
111 |
112 | ```php
113 | public function setElement(string! name, var value) -> void;
114 | ```
115 |
116 | - Argument lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list must be on the next line, and there must be only one argument per line.
117 |
118 | ### PHP Files
119 | PHP files such as tests must follow [PSR-12][psr-12].
120 |
121 |
122 | [php-fig]: https://www.php-fig.org/
123 | [psr-12]: https://www.php-fig.org/psr/psr-12/
124 | [zephir]: https://zephir-lang.com
125 |
--------------------------------------------------------------------------------
/docs/contributions.md:
--------------------------------------------------------------------------------
1 | # Contributions
2 | - - -
3 |
4 | # Contributing to Phalcon
5 | Phalcon is an open source project and relies heavily on volunteer efforts and contributions. We welcome contributions from everyone!
6 |
7 | Please take a few moments to review this document to understand the contribution process and make it as efficient as possible for all. By following these guidelines, we can have faster resolution of issues, better communication, and we can all move the project forward!
8 |
9 | The Phalcon source code (along with documentation, websites etc.) is stored in [GitHub][github]. You can browse our repositories in our [organization page][phalcon-org].
10 |
11 | If you wish to contribute to Phalcon, you can do so by issuing a [GitHub pull request][github-pr].
12 |
13 | When you create a pull request, we have a handy template to help you describe what is the scope of the pull request. It is very important and helpful to the community that you add tests to your pull request. Each pull request will be reviewed by a core contributor (someone with permissions to merge pull requests). Based on the type and content of the pull request, it could be:
14 |
15 | * merged immediately or
16 | * put on hold, where the reviewer requires changes (styling, tests etc.)
17 | * put on hold, if discussion is necessary (community, core team etc.)
18 | * rejected
19 |
20 | !!! warning "NOTE"
21 |
22 | If your pull request is a new feature, it is best to discuss with the core team first, to ensure that it will align with the evolution of the framework.
23 |
24 | !!! danger "NOTE"
25 |
26 | Please make sure that the target branch that you send your pull request is correct and that you have already rebased your code. Pull requests to the **master** branch are not allowed
27 |
28 | ## Documentation
29 | If programming in Zephir seems daunting, there are plenty of areas that you can contribute. You can always check the documentation for any typographic or context errors. You could also enhance the documentation with more examples in the respective pages.
30 |
31 | All you have to do is go to our [docs-apps][phalcon-docs-apps] repository, fork it, make the changes and send us a pull request.
32 |
33 | ## Translations
34 | We have removed the translations from v5.5.x onward. There was not that much traffic from the community to help with translating the documentation to different languages.
35 |
36 | ## Questions and Support
37 |
38 | !!! danger "NOTE"
39 |
40 | We only accept bug reports, new feature requests and pull requests in GitHub. For questions regarding the usage of the framework or support requests please visit the [official discussions page][phalcon-discussions] or our [Discord][phalcon-discord] server.
41 |
42 | ## Bug Report Checklist
43 | - Make sure you are using the latest released version of Phalcon before creating an issue in GitHub.
44 | - Only bugs found in the latest released version of Phalcon will be addressed.
45 | - We have a handy template when creating an issue to help you provide as much information for the core team to reproduce and address. Being able to reproduce a bug significantly reduces the time to find the cause and fix it. Scripts of even failing tests are more than appreciated. Please check how to create the [reproducible tests][tests] page for more information.
46 | - As part of your report, please include additional information such as the OS, PHP version, Phalcon version, web server, memory etc.
47 | - If you're submitting a [Segmentation Fault][segfault] error, we require a backtrace. Please check the [Generating a Backtrace](#generating-a-backtrace) section for more information.
48 |
49 | ### Generating a Backtrace
50 | Sometimes due to [Segmentation Fault][segfault] error, Phalcon could crash some of your web server processes. In order to help us find the cause of this segmentation fault, we will need the crash backtrace.
51 |
52 | Please check the following links for instructions on how to generate the backtrace:
53 |
54 | * [Generating a gdb backtrace][gdb]
55 | * [Generating a backtrace, with a compiler, on Win32][gdb-w32]
56 | * [Debugging Symbols][symbols]
57 | * [Building PHP][building-php]
58 |
59 | ## Pull Request Checklist
60 | - Pull requests to the `master` branch are not accepted. Please fork the repository and create your branch from the necessary "source" branch, for instance `4.0.x` and if need be rebase your branch before submitting your pull request. If there are collisions, we will ask you to rebase your branch again.
61 | - Add tests to your pull request or adjust existing ones. This is very important since it helps justify your pull request. Please check our [testing][env] page for more information on how to set up a test environment and how to write tests.
62 | - Since Phalcon is written in [Zephir][zephir], please do not submit commits that modify the C generated files directly
63 | - Phalcon follows a specific coding style. Please install the `editorconfig` plugin in your favorite IDE to take advantage of the supplied `.editorconfig` file that comes with this repository and not to have to worry about coding standards. All tests (PHP code), follow the [PSR-12][psr-12] standard
64 | - Remove any change to `ext/kernel`, `*.zep.c` and `*.zep.h` files before submitting the pull request
65 | - More information [here][pr].
66 |
67 | Before submitting **new functionality**, please open a [NFR][nfr] as a new issue on GitHub to discuss the impact of including the functionality or changes in the core extension. Once the functionality is approved, make sure your PR contains the following:
68 |
69 | - An update to the `CHANGELOG.md`
70 | - Unit Tests
71 | - Documentation or Usage Examples
72 |
73 | ## Getting Support
74 | If you have any questions about how to use Phalcon, please see the [support page][support].
75 |
76 | ## Requesting Features
77 | If you have any changes or new features in mind, please fill an [NFR][nfr].
78 |
79 | Thanks!
80 |
81 |
82 | <3 Phalcon Team
83 |
84 | [github]: https://github.com
85 | [phalcon-org]: https://github.com/phalcon
86 | [github-pr]: https://help.github.com/articles/using-pull-requests/
87 | [phalcon-docs-app]: https://github.com/phalcon/docs-app
88 | [phalcon-discussions]: https://phalcon.io/discussions
89 | [phalcon-discord]: https://phalcon.io/discord
90 | [tests]: reproducible-tests.md
91 | [segfault]: https://en.wikipedia.org/wiki/Segmentation_fault
92 | [gdb]: https://bugs.php.net/bugs-generating-backtrace.php
93 | [gdb-w32]: https://bugs.php.net/bugs-generating-backtrace-win32.php
94 | [symbols]: https://github.com/oerdnj/deb.sury.org/wiki/Debugging-symbols
95 | [building-php]: https://www.phpinternalsbook.com/build_system/building_php.html
96 | [env]: testing-environment.md
97 | [zephir]: https://zephir-lang.com
98 | [psr-12]: https://www.php-fig.org/psr/
99 | [pr]: new-pull-request.md
100 | [nfr]: new-feature-request.md
101 | [support]: https://phalcon.io/support
102 |
--------------------------------------------------------------------------------
/docs/datamapper.md:
--------------------------------------------------------------------------------
1 | # Data Mapper
2 | - - -
3 |
4 | !!! info "NOTE"
5 |
6 | These components have been heavily influenced by [Aura PHP][auraphp] and [Atlas PHP][atlasphp]
7 |
8 | ## Overview
9 |
10 | The Data Mapper pattern as described by [Martin Fowler][datamapper] in [Patterns of Enterprise Application Architecture][eaa] is:
11 |
12 | !!! info "NOTE"
13 |
14 | A layer of Mappers that moves data between objects and a database while keeping them independent of each other and the mapper itself.
15 |
16 | The `Phalcon\DataMapper` namespace contains components to help with accessing your data source, with the [Data Mapper][pattern].
17 |
18 | ## PDO
19 |
20 | ### Connection
21 |
22 | One of the components required by this implementation is a PDO connector. The [Phalcon\DataMapper\Pdo\Connection][datamapper-pdo-connection] offers a wrapper to PHP's PDO implementation, making it easier to maintain connections.
23 |
24 | **Connecting to a source**
25 |
26 | ### Connection - Decorated
27 | ### ConnectionLocator
28 |
29 | ### Profiler
30 | ## Query
31 | ### Factory
32 | ### Delete
33 | ### Insert
34 | ### Select
35 | ### Update
36 |
37 | [auraphp]: https://github.com/auraphp
38 | [atlasphp]: https://github.com/atlasphp
39 | [datamapper]: https://martinfowler.com/eaaCatalog/dataMapper.html
40 | [datamapper-pdo-connection]: api/phalcon_datamapper.md#datamapper-pdo-connection
41 | [datamapper-pdo-connection-abstractconnection]: api/phalcon_datamapper.md#datamapper-pdo-connection-abstractconnection
42 | [datamapper-pdo-connection-connectioninterface]: api/phalcon_datamapper.md#datamapper-pdo-connection-connectioninterface
43 | [datamapper-pdo-connection-decorated]: api/phalcon_datamapper.md#datamapper-pdo-connection-decorated
44 | [datamapper-pdo-connection-pdointerface]: api/phalcon_datamapper.md#datamapper-pdo-connection-pdointerface
45 | [datamapper-pdo-connectionlocator]: api/phalcon_datamapper.md#datamapper-pdo-connectionlocator
46 | [datamapper-pdo-connectionlocatorinterface]: api/phalcon_datamapper.md#datamapper-pdo-connectionlocatorinterface
47 | [datamapper-pdo-exception-cannotdisconnect]: api/phalcon_datamapper.md#datamapper-pdo-exception-cannotdisconnect
48 | [datamapper-pdo-exception-connectionnotfound]: api/phalcon_datamapper.md#datamapper-pdo-exception-connectionnotfound
49 | [datamapper-pdo-exception-exception]: api/phalcon_datamapper.md#datamapper-pdo-exception-exception
50 | [datamapper-pdo-profiler-memorylogger]: api/phalcon_datamapper.md#datamapper-pdo-profiler-memorylogger
51 | [datamapper-pdo-profiler-profiler]: api/phalcon_datamapper.md#datamapper-pdo-profiler-profiler
52 | [datamapper-pdo-profiler-profilerinterface]: api/phalcon_datamapper.md#datamapper-pdo-profiler-profilerinterface
53 | [datamapper-query-abstractconditions]: api/phalcon_datamapper.md#datamapper-query-abstractconditions
54 | [datamapper-query-abstractquery]: api/phalcon_datamapper.md#datamapper-query-abstractquery
55 | [datamapper-query-bind]: api/phalcon_datamapper.md#datamapper-query-bind
56 | [datamapper-query-delete]: api/phalcon_datamapper.md#datamapper-query-delete
57 | [datamapper-query-insert]: api/phalcon_datamapper.md#datamapper-query-insert
58 | [datamapper-query-queryfactory]: api/phalcon_datamapper.md#datamapper-query-queryfactory
59 | [datamapper-query-select]: api/phalcon_datamapper.md#datamapper-query-select
60 | [datamapper-query-update]: api/phalcon_datamapper.md#datamapper-query-update
61 | [eaa]: https://martinfowler.com/books/eaa.html
62 |
--------------------------------------------------------------------------------
/docs/db-migrations.md:
--------------------------------------------------------------------------------
1 | # Database Migrations
2 | - - -
3 |
4 | !!! info "NOTE"
5 |
6 | Phalcon migrations have been removed from DevTools and moved to a separate repository.
7 |
8 | ## Package git repository
9 |
10 | https://github.com/phalcon/migrations
11 |
12 | ## Requirements
13 |
14 | * PHP >= 7.5
15 | * Phalcon >= 5.0.0
16 |
17 | ## Installing via Composer
18 |
19 | ```
20 | composer require --dev phalcon/migrations
21 | ```
22 |
23 | ## Quick start
24 |
25 | What you need for quick start:
26 |
27 | * Configuration file in root of your project (you can also pass them as parameters inside CLI environment)
28 | * Create database tables structure
29 | * Execute command to generate migrations
30 |
31 | After that you can execute that migrations (run) in another environment to create same DB structure.
32 |
33 | ### Create configuration file
34 |
35 | ```php
36 | [
42 | 'adapter' => 'mysql',
43 | 'host' => '127.0.0.1',
44 | 'username' => 'root',
45 | 'password' => '',
46 | 'dbname' => 'db-name',
47 | 'charset' => 'utf8',
48 | ],
49 | 'application' => [
50 | 'logInDb' => true,
51 | 'migrationsDir' => 'db/migrations',
52 | // true - TIMESTAMP, false - versions
53 | 'migrationsTsBased' => true,
54 | 'exportDataFromTables' => [
55 | // Tables names
56 | ],
57 | ],
58 | ]);
59 | ```
60 |
61 | !!! info "NOTE"
62 |
63 | If `exportDataFromTables` is set, data will be exported with every migration
64 |
65 | ### Generate migrations
66 |
67 | **Basic generation**
68 |
69 | ```
70 | vendor/bin/phalcon-migrations generate
71 | ```
72 |
73 | **Generate specific table and export data from it
74 |
75 | ```
76 | vendor/bin/phalcon-migrations generate \
77 | --config=migrations.php \
78 | --table=users \
79 | --exportDataFromTables=users \
80 | --data=oncreate
81 | ```
82 |
83 | ### Run migrations
84 |
85 | ```
86 | vendor/bin/phalcon-migrations run
87 | ```
88 |
89 | ### List existing migrations
90 |
91 | ```
92 | vendor/bin/phalcon-migrations list
93 | ```
94 |
95 | ## Usage example
96 |
97 | **Run migrations from specific migrations directory**
98 |
99 | ```php
100 | [
107 | __DIR__ . '/migrations',
108 | ],
109 | 'config' => [
110 | 'database' => [
111 | 'adapter' => 'Mysql',
112 | 'host' => 'phalcon-db-mysql',
113 | 'username' => 'root',
114 | 'password' => 'root',
115 | 'dbname' => 'vokuro',
116 | ],
117 | ]
118 | ]);
119 | ```
120 |
121 | ## Migration methods
122 |
123 | Each migration is a separate class that works as an entity for specific database table.
124 | Inside each class there are different methods that can occur during migration running.
125 |
126 | Each migration file (and class) can implement specific methods, that will be executed based on the operation requested.
127 | There are no restrictions on the logic encapsulated in each method.
128 |
129 | The tables below show the Migration Class methods. They are stored by order of execution, earliest to latest.
130 |
131 | **Running to up**
132 |
133 | | Method name | Description |
134 | |--------------------|----------------------------------------------------|
135 | | `morph` | Morph table structure |
136 | | `afterCreateTable` | Make something immediately after table was created |
137 | | `up` | Table is created and ready to work with |
138 | | `afterUp` | Extra method to work for some specific cases |
139 |
140 |
141 | **Running to down**
142 |
143 | | Method name | Description |
144 | |-------------|--------------------------------------------------------------------------------------------------------------------|
145 | | `down` | Normally you put here table drop or data truncation |
146 | | `aferDown` | Extra method to work after all was cleaned up |
147 | | `morph` | (**from previous migration**) As the migration was moved backward, there need to be all returned to previous state |
148 |
149 | ## CLI Arguments and options
150 |
151 | **Arguments**
152 |
153 | | Argument | Description |
154 | |------------|-------------------------------|
155 | | `generate` | Generate a Migration |
156 | | `run` | Run a Migration |
157 | | `list` | List all available migrations |
158 |
159 | **Options**
160 |
161 | | Action | Description |
162 | |----------------------------|------------------------------------------------------------------------------------------|
163 | | `--config=s` | Configuration file |
164 | | `--migrations=s` | Migrations directory. Use comma separated string to specify multiple directories |
165 | | `--directory=s` | Directory where the project was created |
166 | | `--table=s` | Table to migrate. Table name or table prefix with asterisk. Default: all |
167 | | `--version=s` | Version to migrate |
168 | | `--descr=s` | Migration description (used for timestamp based migration) |
169 | | `--data=s` | Export data ['always' or 'oncreate'] (Data is imported during migration run) |
170 | | `--exportDataFromTables=s` | Export data from specific tables, use comma separated string |
171 | | `--force` | Forces to overwrite existing migrations |
172 | | `--ts-based` | Timestamp based migration version |
173 | | `--log-in-db` | Keep migrations log in the database table rather then in file |
174 | | `--dry` | Attempt requested operation without making changes to system (Generating only) |
175 | | `--verbose` | Output of debugging information during operation (Running only) |
176 | | `--no-auto-increment` | Disable auto increment (Generating only) |
177 | | `--skip-ref-schema` | Skip referencedSchema inside generated migration (Generating only) |
178 | | `--skip-foreign-checks` | Wrap `SET FOREIGN_KEY_CHECKS` query before and after execution of a query (Running only) |
179 | | `--help` | Shows this help |
180 |
181 | ## Timestamp based migrations
182 |
183 | Using this approach is useful when more than one developer is participating in the database structure management.
184 | Use `'migrationsTsBased' => true` in config file or `--ts-based` option in CLI environment.
185 | Also, you need to specify suffix `descr`, which could be anything you want, for example: semantic version.
186 |
187 | Current command
188 | ```
189 | vendor/bin/phalcon-migrations generate --ts-based --descr=1.0.0
190 | ```
191 |
192 | Will produce folder name with such names
193 |
194 | ```sh
195 | * 1582539287636860_1.0.0
196 | * 1682539471102635_1.0.0
197 | * 1782539471102635_1.0.0
198 | ```
199 |
200 | Migrations will be executed from oldest to newest.
201 |
202 | !!! info "NOTE"
203 |
204 | Whenever migrations are run, the application scans all available migrations and their status irrespective of their "age". If one or more were not executed in a previous run, they will be executed in the next run.
205 |
--------------------------------------------------------------------------------
/docs/db-models-validation.md:
--------------------------------------------------------------------------------
1 | # Model Validation
2 | - - -
3 |
4 | ## Overview
5 | [Phalcon\Mvc\Model][mvc-model] provides several events to validate data and implement business rules.
6 |
7 | ```php
8 | add(
23 | 'cst_email',
24 | new Uniqueness(
25 | [
26 | 'message' => 'The customer email must be unique',
27 | ]
28 | )
29 | );
30 |
31 | return $this->validate($validator);
32 | }
33 | }
34 | ```
35 |
36 | ## Data Integrity
37 | Data integrity is essential in every application. You can implement validators in your models to introduce another layer of validation so that you can ensure that data is stored in your database that enforce your business rules.
38 |
39 | The special `validation` event allows us to call built-in validators on the record. Phalcon exposes additional built-in validators that can be used at this stage of validation. All validators available are under the [Phalcon\Validation][filter-validation] namespace.
40 |
41 | ```php
42 | add(
58 | 'inv_status_flag',
59 | new InclusionIn(
60 | [
61 | 'domain' => [
62 | 'Paid',
63 | 'Unpaid',
64 | ],
65 | 'message' => 'The invoice must be ' .
66 | 'either paid or unpaid',
67 | ]
68 | )
69 | );
70 |
71 | $validator->add(
72 | 'inv_number',
73 | new Uniqueness(
74 | [
75 | 'message' => 'The invoice number must be unique',
76 | ]
77 | )
78 | );
79 |
80 | return $this->validate($validator);
81 | }
82 | }
83 | ```
84 |
85 | The above example performs a validation using the built-in validator [Phalcon\Filter\Validation\Validator\InclusionIn][validation-validator-inclusionin]. It checks the value of the field `inv_status_flag` in a domain list. If the value is not included in the method then the validator will fail and return `false`.
86 |
87 | !!! warning "NOTE"
88 |
89 | For more information on validators, see the [Validation documentation][filter-validation]
90 |
91 | ## Messages
92 | [Phalcon\Mvc\Model][mvc-model] utilizes the [Phalcon\Messages\Messages][messages-messages] collection to store any validation messages that have been generated during the validation process.
93 |
94 | Each message is an instance of [Phalcon\Messages\Message][messages-message] and the set of messages generated can be retrieved with the `getMessages()` method. Each message provides additional information such as the field name that generated the message or the message type:
95 |
96 | ```php
97 | save()) {
100 | $messages = $invoice->getMessages();
101 |
102 | foreach ($messages as $message) {
103 | echo 'Message: ', $message->getMessage();
104 | echo 'Field: ', $message->getField();
105 | echo 'Type: ', $message->getType();
106 | }
107 | }
108 | ```
109 |
110 | [Phalcon\Mvc\Model][mvc-model] can generate the following types of validation messages:
111 |
112 | | Type | Generated when |
113 | |------------------------|------------------------------------------------------------------------------------------------------------------------|
114 | | `ConstraintViolation` | A field, part of a virtual foreign key, is trying to insert/update a value that does not exist in the referenced model |
115 | | `InvalidCreateAttempt` | Trying to create a record that already exists |
116 | | `InvalidUpdateAttempt` | Trying to update a record that does not exist |
117 | | `InvalidValue` | A validator failed because of an invalid value |
118 | | `PresenceOf` | A field with a non `null` attribute on the database is trying to insert/update a `null` value |
119 |
120 | The `getMessages()` method can be overridden in a model to replace/translate the default messages generated automatically by the ORM:
121 |
122 | ```php
123 | getType()) {
137 | case 'InvalidCreateAttempt':
138 | $messages[] = 'The record cannot be created '
139 | . 'because it already exists';
140 | break;
141 |
142 | case 'InvalidUpdateAttempt':
143 | $messages[] = "The record cannot be updated '
144 | . 'because it doesn't exist";
145 | break;
146 |
147 | case 'PresenceOf':
148 | $messages[] = 'The field '
149 | . $message->getField()
150 | . ' is mandatory';
151 | break;
152 | }
153 | }
154 |
155 | return $messages;
156 | }
157 | }
158 | ```
159 |
160 | ## Failed Events
161 | Additional events are available when the data validation process finds any inconsistencies:
162 |
163 | | Operation | Name | Explanation |
164 | |--------------------------|---------------------|------------------------------------------------------------------------|
165 | | Insert or Update | `notSaved` | Triggered when the `INSERT` or `UPDATE` operation fails for any reason |
166 | | Insert, Delete or Update | `onValidationFails` | Triggered when any data manipulation operation fails |
167 |
168 |
169 | ## Custom
170 | The [validation][filter-validation] document explains in detail how you can create your own validators. You can use such validators and reuse them among several models. A validator also can be as simple as:
171 |
172 | ```php
173 | inv_type_flag) {
185 | $message = new Message(
186 | 'Unpaid invoices are not allowed',
187 | 'inv_type_flag',
188 | 'UnpaidInvoiceType'
189 | );
190 |
191 | $this->appendMessage($message);
192 |
193 | return false;
194 | }
195 |
196 | return true;
197 | }
198 | }
199 | ```
200 |
201 | [mvc-model]: api/phalcon_mvc.md#mvc-model
202 | [mvc-model-validationfailed]: api/phalcon_mvc.md#mvc-model-validationfailed
203 | [validation-validator-inclusionin]: api/phalcon_filter.md#filter-validation-validator-inclusionin
204 | [messages-message]: api/phalcon_messages.md#messages-message
205 | [messages-messages]: api/phalcon_messages.md#messages-messages
206 | [filter-validation]: filter-validation.md
207 |
--------------------------------------------------------------------------------
/docs/db-odm.md:
--------------------------------------------------------------------------------
1 | # Object Document Mapper
2 | - - -
3 |
4 | !!! warning "NOTE"
5 |
6 | The Object Document Mapper functionality has been **temporarily** removed for v4.0+.
7 |
8 | The existing implementation was using a PHP MongoDB driver that has been deprecated for years. As such, work is underway to re-introduce the Object Document Mapper in Phalcon, using the latest MongoDB PHP driver.
9 |
10 | We expect this functionality to be reintroduced a future Phalcon release.
11 |
--------------------------------------------------------------------------------
/docs/domain.md:
--------------------------------------------------------------------------------
1 | # Domain
2 | - - -
3 |
4 | !!! warning "NOTE"
5 |
6 | In future versions of Phalcon, this component will be reworked to follow the [Payload Interop][payload-interop] interface.
7 |
8 | The domain component incorporates components that are used for the implementation of the [Action Domain Responder][adr] ([ADR][adr-jones]) pattern and can also be used when implementing [Domain Driven Design][ddd].
9 |
10 | ## Payload
11 | The [Action Domain Responder][adr] requires a data transfer mechanism between the three layers to serve your application. The [Phalcon\Domain\Payload][payload-payload] is a data transfer object that is used to send data between the three layers of the pattern.
12 |
13 | ```php
14 | newInstance();
48 | ?>
49 | ```
50 |
51 | ## Interfaces
52 | There are three interfaces that you can take advantage of if you wish to extend the object.
53 |
54 | | Interface | Description |
55 | |---------------------|--------------------------------------|
56 | | `ReadableInterface` | contains only read methods |
57 | | `WritableInterface` | contains only write methods |
58 | | `PayloadInterface` | contains both read and write methods |
59 |
60 | ## Status Values
61 | The [Phalcon\Domain\Payload\Status][payload-status] class contains several constants to help with the domain status of your Payload objects. You can always extend the class and introduce your own domain statuses, depending on the needs of your application.
62 |
63 | * `ACCEPTED`
64 | * `AUTHENTICATED`
65 | * `AUTHORIZED`
66 | * `CREATED`
67 | * `DELETED`
68 | * `ERROR`
69 | * `FAILURE`
70 | * `FOUND`
71 | * `NOT_ACCEPTED`
72 | * `NOT_AUTHENTICATED`
73 | * `NOT_AUTHORIZED`
74 | * `NOT_CREATED`
75 | * `NOT_DELETED`
76 | * `NOT_FOUND`
77 | * `NOT_UPDATED`
78 | * `NOT_VALID`
79 | * `PROCESSING`
80 | * `SUCCESS`
81 | * `UPDATED`
82 | * `VALID`
83 |
84 | These statuses can be used at the display/view layer of your application to process domain objects retrieved via `Payload::getOutput()`.
85 |
86 | ## Example
87 | ```php
88 | newInstance();
101 |
102 | $report = Reports::find(
103 | [
104 | 'conditions' => 'reportId = :reportId:',
105 | 'bind' => [
106 | 'reportId' => $reportId,
107 | ],
108 | ]
109 | );
110 |
111 | if (false === $report) {
112 | $payload
113 | ->setStatus(Status::NOT_FOUND)
114 | ->setInput(func_get_args())
115 | ;
116 | } else {
117 | $payload
118 | ->setStatus(Status::FOUND)
119 | ->setOutput($report)
120 | ;
121 | }
122 |
123 | return $payload;
124 | }
125 | }
126 | ```
127 |
128 | ## Links
129 |
130 | * [Action Domain Responder][adr]
131 | * [Clarifications to a review of Action Domain Responder][adr-clarifications]
132 | * [Payload Interop][payload-interop]
133 |
134 |
135 | [adr]: https://en.wikipedia.org/wiki/Action%E2%80%93domain%E2%80%93responder
136 | [adr-jones]: https://pmjones.io/adr/
137 | [adr-clarifications]: https://paul-m-jones.com/post/2018/12/19/clarifications-to-a-review-of-action-domain-responder/
138 | [ddd]: https://en.wikipedia.org/wiki/Domain-driven_design
139 | [payload-interop]: https://github.com/payload-interop/payload-interop
140 | [payload-payload]: api/phalcon_domain.md#domain-payload-payload
141 | [payload-payloadfactory]: api/phalcon_domain.md#domain-payload-payloadfactory
142 | [payload-payloadinterface]: api/phalcon_domain.md#domain-payload-payloadinterface
143 | [payload-readableinterface]: api/phalcon_domain.md#domain-payload-readableinterface
144 | [payload-status]: api/phalcon_domain.md#domain-payload-status
145 | [payload-writeableinterface]: api/phalcon_domain.md#domain-payload-writeableinterface
146 |
--------------------------------------------------------------------------------
/docs/environments-devilbox.md:
--------------------------------------------------------------------------------
1 | # Environments
2 | - - -
3 |
4 | ## Overview
5 |
6 | [Devilbox][devilbox] is a modern and highly customizable dockerized PHP stack supporting full LAMP and MEAN and running on all major platforms. The main goal is to easily switch and combine any version required for local development. It supports an unlimited number of projects for which vhosts, SSL certificates and DNS records are created automatically. Reverse proxies per project are supported to ensure listening server such as NodeJS can also be reached. Email catch-all and popular development tools will be at your service as well. Configuration is not necessary, as everything is already pre-setup.
7 |
8 | Furthermore, the Devilbox provides an identical and reproducible development environment for different host operating systems.
9 |
10 | This example will use `phalcon` to install Phalcon from within the Devilbox PHP container. After completing the steps listed below, you will have a working Phalcon setup ready to be served via http and https.
11 |
12 |
13 | ## Configuration
14 |
15 | The following configuration will be used:
16 |
17 | | Setting | Value |
18 | |-----------------------|---------------------------------------------------|
19 | | Project name | `my-phalcon` |
20 | | VirtualHost directory | `/shared/httpd/my-phalcon` |
21 | | Database | n.a. |
22 | | `TLD_SUFFIX` | loc |
23 | | Project URL | `http://my-phalcon.loc`, `https://my-phalcon.loc` |
24 |
25 |
26 | !!! info "NOTE"
27 |
28 | * Inside the Devilbox PHP container, projects are always in `/shared/httpd/`.
29 | * On your host operating system, projects are by default in `./data/www/` inside the Devilbox git directory. This path can be changed via `HOST_PATH_HTTPD_DATADIR`.
30 |
31 | ## Activation
32 |
33 | Your environment will be ready in six simple steps:
34 |
35 | - Enter the PHP container
36 | - Create a new VirtualHost directory
37 | - Install Phalcon
38 | - Symlink webroot directory
39 | - Setup DNS record
40 | - Visit `http://my-phalcon.loc` in your browser
41 | - (Nginx) Create custom vhost config file
42 |
43 |
44 | ### Enter the PHP Container
45 |
46 | All the work will be performed inside the PHP container since it offers all the necessary tools. Navigate to the Devilbox git directory and execute `./shell.sh` (or `shell.bat` on Windows) to enter the running PHP container.
47 |
48 | ```bash
49 | host> ./shell.sh
50 | ```
51 |
52 | ### Create New Vhost Directory
53 |
54 | The vhost directory defines the name under which your project will be available. (`.TLD_SUFFIX` will be the final URL ).
55 |
56 | ```bash
57 | devilbox@php-8.0 in /shared/httpd $ mkdir my-phalcon
58 | ```
59 |
60 | ### Install Phalcon
61 |
62 | Navigate into your newly created vhost directory and install Phalcon with `phalcon` cli.
63 |
64 | ```bash
65 | devilbox@php-8.0 in /shared/httpd $ cd my-phalcon
66 | devilbox@php-8.0 in /shared/httpd/my-phalcon $ phalcon project phalconphp
67 | ```
68 |
69 | The directory structure looks like this after the installation:
70 |
71 | ```bash
72 | devilbox@php-8.0 in /shared/httpd/my-phalcon $ tree -L 1
73 | .
74 | └── phalconphp
75 |
76 | 1 directory, 0 files
77 | ```
78 |
79 | ### Symlink Webroot
80 |
81 | Symlinking the actual webroot directory to `htdocs` is important. The web server expects every project's document root to be in `/htdocs/`. This is the path where it will serve the files. This is also the path where the entry point of your application (usually `index.php`) needs to reside.
82 |
83 | Some frameworks however, store files and content in nested directories of unknown levels. It is therefore impossible to set this as a pre-set for the environment. You will therefore have to manually set a symlink back to the expected path that your framework requires.
84 |
85 | ```bash
86 | devilbox@php-8.0 in /shared/httpd/my-phalcon $ ln -s phalconphp/public/ htdocs
87 | ```
88 |
89 | The directory structure looks like this after the installation:
90 |
91 | ```bash
92 | devilbox@php-8.0 in /shared/httpd/my-phalcon $ tree -L 1
93 | .
94 | ├── phalconphp
95 | └── htdocs -> phalconphp/public
96 |
97 | 2 directories, 0 files
98 | ```
99 |
100 | As you can see in the above listing, the `htdocs` folder that is required by the web server is now pointing to the entry point of your framework.
101 |
102 | !!! warning "NOTE"
103 |
104 | When using **Docker Toolbox**, you need to **explicitly allow** the usage of **symlinks**.
105 |
106 | ### DNS Record
107 |
108 | If you **have** Auto DNS configured already, you can skip this section, because DNS entries will be available automatically by the bundled DNS server.
109 |
110 | If you **do not have** Auto DNS configured, you will need to add the following line to your host operating system `/etc/hosts` file (or `C:\Windows\System32\drivers\etc` on Windows):
111 |
112 | ```bash
113 | 127.0.0.1 my-phalcon.loc
114 | ```
115 |
116 | ### Open your Browser
117 |
118 | Open your browser and navigate to `http://my-phalcon.loc` or `https://my-phalcon.loc`
119 |
120 |
121 | ### Create Custom Vhost Config File (Nginx Only)
122 |
123 | By default routes will not work if using Nginx. To fix this, you will need to create a custom vhost configuration.
124 |
125 | In your project folder, you will need to create a folder called `.devilbox` unless you changed `HTTPD_TEMPLATE_DIR` in your `.env`
126 |
127 | Copy the default nginx config from `./cfg/vhost-gen/nginx.yml-example-vhost` to `./data/www/my-project/.devilbox/nginx.yml`
128 |
129 | Carefully edit the nginx.yml file and change:
130 |
131 | `try_files $uri $uri/ /index.php$is_args$args;`
132 |
133 | to
134 |
135 | `try_files $uri $uri/ /index.php?_url=$uri&$args;`
136 |
137 | and
138 |
139 | `location ~ \.php?$ {`
140 |
141 | to
142 |
143 | `location ~ [^/]\.php(/|$) {`
144 |
145 | Save the file as `nginx.yml` and ensure not to use any tabs in the file or devilbox will not use the custom configuration. You can use `yamllint nginx.yml` whilst inside the Devilbox shell to check the file before restarting devilbox.
146 |
147 | ## References
148 | - [Devilbox.com][devilbox]
149 | - [Devilbox Documentation][devilbox-documentation]
150 | - [HOST_PATH_HTTPD_DATADIR][host-path-httpd-datadir]
151 | - [Enter the PHP container][enter-container]
152 | - [Work inside the PHP container][work-in-container]
153 | - [Available tools][available-tools]
154 | - [TLD_SUFFIX][tld-suffix]
155 | - [Docker Toolbox and Symlinks][docker-toolbox-symlinks]
156 | - [Add project hosts entry on MacOS][hosts-mac]
157 | - [Add project hosts entry on Windows][hosts-windows]
158 | - [Setup Auto DNS][auto-dns]
159 |
160 | [devilbox]: https://devilbox.org
161 | [devilbox-documentation]: https://devilbox.readthedocs.io/en/latest/examples/setup-phalcon.html
162 | [host-path-httpd-datadir]: https://devilbox.readthedocs.io/en/latest/configuration-files/env-file.html#env-httpd-datadir
163 | [enter-container]: https://devilbox.readthedocs.io/en/latest/getting-started/enter-the-php-container.html#enter-the-php-container
164 | [work-in-container]: https://devilbox.readthedocs.io/en/latest/intermediate/work-inside-the-php-container.html#work-inside-the-php-container
165 | [available-tools]: https://devilbox.readthedocs.io/en/latest/readings/available-tools.html#available-tools
166 | [tld-suffix]: https://devilbox.readthedocs.io/en/latest/configuration-files/env-file.html#env-tld-suffix
167 | [docker-toolbox-symlinks]: https://devilbox.readthedocs.io/en/latest/howto/docker-toolbox/docker-toolbox-and-the-devilbox.html#howto-docker-toolbox-and-the-devilbox-windows-symlinks
168 | [hosts-mac]: https://devilbox.readthedocs.io/en/latest/howto/dns/add-project-dns-entry-on-mac.html#howto-add-project-hosts-entry-on-mac
169 | [hosts-windows]: https://devilbox.readthedocs.io/en/latest/howto/dns/add-project-dns-entry-on-win.html#howto-add-project-hosts-entry-on-win
170 | [auto-dns]: https://devilbox.readthedocs.io/en/latest/intermediate/setup-auto-dns.html#setup-auto-dns
171 |
--------------------------------------------------------------------------------
/docs/environments-nanobox.md:
--------------------------------------------------------------------------------
1 | # Environments
2 | - - -
3 |
4 | !!! info "NOTE"
5 |
6 | [Nanobox][nanobox] has been discontinued.
7 |
8 | [nanobox]: https://nanobox.io
9 |
--------------------------------------------------------------------------------
/docs/generating-backtrace.md:
--------------------------------------------------------------------------------
1 | # Generating a Backtrace
2 | - - -
3 |
4 | Phalcon is compiled into a C extension loaded on your web server. Because of that, bugs lead to segmentation faults, causing Phalcon to crash some of your web server processes.
5 |
6 | For debugging these segmentation faults a stacktrace is required. Creating a stack trace requires a special build of php and some steps need to be done to generate a trace that allows the Phalcon team to debug this behavior.
7 |
8 | Please follow this guide to understand how to generate the backtrace.
9 |
10 | [https://bugs.php.net/bugs-generating-backtrace.php](https://bugs.php.net/bugs-generating-backtrace.php)
11 |
12 | [https://bugs.php.net/bugs-generating-backtrace-win32.php](https://bugs.php.net/bugs-generating-backtrace-win32.php)
13 |
--------------------------------------------------------------------------------
/docs/html-attributes.md:
--------------------------------------------------------------------------------
1 | # HTML Components
2 | - - -
3 |
4 | ## Overview
5 | The [Phalcon\Html\Attributes][html-attributes] is a wrapper of [Phalcon\Support\Collection][support-collection]. It also contains two more methods `render()` and `__toString()`. `render()` uses [Phalcon\Html\TagFactory][html-tagfactory] internally to render the attributes that an HTML element has. These HTML attributes are defined in the object itself.
6 |
7 | The component can be used on its own if you want to collect HTML attributes in an object and then _render_ them (return them as a string) in a `key=value` format.
8 |
9 | This component is used internally by [Phalcon\Forms\Form][forms] to store the attributes of form elements.
10 |
11 | [html-attributes]: api/phalcon_html.md#html-attributes
12 | [html-attributes-attributesinterface]: api/phalcon_html.md#html-attributes-attributesinterface
13 | [html-attributes-renderinterface]: api/phalcon_html.md#html-attributes-renderinterface
14 | [html-tagfactory]: api/phalcon_html.md#html-tagfactory
15 | [support-collection]: support-collection.md
16 | [forms]: forms.md
17 |
--------------------------------------------------------------------------------
/docs/html-breadcrumbs.md:
--------------------------------------------------------------------------------
1 | # HTML Components
2 | - - -
3 |
4 | ## Overview
5 | A common piece of HTML that is present in many web applications is the breadcrumbs. These are links separated by a space or by the `/` character usually, that represent the tree structure of an application. The purpose is to give users another easy visual way to navigate throughout the application.
6 |
7 | An example is an application that has an `admin` module, an `invoices` area and a `view invoice` page. Usually, you would select the `admin` module, then from the links you will choose `invoices` (list) and then clicking on one of the invoices in the list, you can view it. To represent this tree like structure, the breadcrumbs displayed could be:
8 |
9 | ```php
10 | Home / Admin / Invoices / Viewing Invoice [1234]
11 | ```
12 | Each of the words above (apart from the last one) are links to the respective pages. This way the user can quickly navigate back to a different area without having to click the back button or use another menu.
13 |
14 | [Phalcon\Html\Breadcrumbs][html-breadcrumbs] offers functionality to add text and URLs. The resulting HTML when calling `render()` will have each breadcrumb enclosed in `
` tags, while the whole string is enclosed in `
` tags.
15 |
16 | ### Methods
17 | ```php
18 | public function add(
19 | string $label,
20 | string $link = ""
21 | ): Breadcrumbs
22 | ```
23 | Adds a new crumb.
24 |
25 | In the example below, add a crumb with a link and then add a crumb without a link (normally the last one)
26 |
27 | ```php
28 | $breadcrumbs
29 | ->add("Home", "/")
30 | ->add("Users")
31 | ;
32 | ```
33 |
34 | ```php
35 | public function clear(): void
36 | ```
37 | Clears the crumbs
38 |
39 | ```php
40 | $breadcrumbs->clear()
41 | ```
42 |
43 | ```php
44 | public function getSeparator(): string
45 | ```
46 | Returns the separator used for the breadcrumbs
47 |
48 | ```php
49 | public function remove(string $link): void
50 | ```
51 | Removes crumb by url.
52 |
53 | In the example below remove a crumb by URL and also remove a crumb without an url (last link)
54 |
55 | ```php
56 | $breadcrumbs->remove("/admin/user/create");
57 | $breadcrumbs->remove();
58 | ```
59 |
60 | ```php
61 | public function render(): string
62 | ```
63 | Renders and outputs breadcrumbs HTML. The template used is:
64 |
65 | ```html
66 |
71 | ```
72 | The last set crumb will not have a link and will only have its text displayed. Each crumb is wrapped in `` tags. The whole collection is wrapped in `
` tags. You can use them in conjunction with CSS to format the crumbs on screen according to the needs of your application.
73 |
74 | ```php
75 | echo $breadcrumbs->render();
76 | ```
77 |
78 | ```php
79 | public function setSeparator(string $separator)
80 | ```
81 | The default separator between the crumbs is `/`. You can set a different one if you wish using this method.
82 |
83 | ```php
84 | $breadcrumbs->setSeparator('-');
85 | ```
86 |
87 | ```php
88 | public function toArray(): array
89 | ```
90 | Returns the internal breadcrumbs array
91 |
92 | [html-breadcrumbs]: api/phalcon_html.md#html-breadcrumbs
93 | [html-exception]: api/phalcon_html.md#html-exception
94 | [html-tagfactory]: api/phalcon_html.md#html-tagfactory
95 |
--------------------------------------------------------------------------------
/docs/html-link.md:
--------------------------------------------------------------------------------
1 | # HTML Link
2 | - - -
3 |
4 | ## Overview
5 | [Phalcon\Html\Link\EvolvableLink][html-link-evolvablelink], [Phalcon\Html\Link\EvolvableLinkProvider][html-link-evolvablelinkprovider], [Phalcon\Html\Link\Link][html-link-link] and [Phalcon\Html\Link\LinkProvider][html-link-linkprovider] are classes that implement the interfaces based on [PSR-13][psr-13], but with much stricter types
6 |
7 | !!! info "NOTE"
8 |
9 | This component does not generate any HTML links. It just stores the links. You will need to create your own serializers that will parse these objects and generate the necessary output. The [Phalcon\Html\Link\Serializer\Header][html-link-serializer-header] serializer is available for you to use.
10 |
11 | ### Operations
12 | The `Phalcon\Html\Link\*` components implement methods that are inline with [PSR-13][psr-13], but do not implement the particular interface. A package that implements [PSR-13][psr-13] is available, that uses the `Phalcon\Html\Link\*` components. The package is located [here][proxy-psr13]. To use it, you will need to have Phalcon installed and then using composer you can install the proxy package.
13 |
14 | ```sh
15 | composer require phalcon/proxy-psr13
16 | ```
17 |
18 | Using the proxy classes allows you to follow [PSR-13][psr-13] and use it with any other package that needs that interface.
19 |
20 | ## Link
21 | The [Phalcon\Html\Link\Link][html-link-link] is used to create a link and assign attributes to it upon construction.
22 |
23 | ```php
24 | true,
31 | 'two' => 123,
32 | 'three' => 'four',
33 | 'five' => [
34 | 'six',
35 | 'seven',
36 | ],
37 | ];
38 |
39 | $link = new Link('payment', $href, $attributes);
40 | ```
41 |
42 | ## LinkProvider
43 | The [Phalcon\Html\Link\LinkProvider][html-link-linkprovider] is used as a container of [Phalcon\Html\Link\Link][html-link-link] objects. You can add them in the provider and then access them as a whole or retrieve them by `rel`.
44 |
45 | ```php
46 | getLinksByRel('cite-as')
60 | );
61 |
62 | // [
63 | // Link('cite-as', 'https://test.phalcon.ld'),
64 | // ]
65 | ```
66 |
67 | ## EvolvableLink
68 | Link objects are immutable. However, there is a need to manipulate them based on your application needs. The [Phalcon\Html\Link\EvolvableLink][html-link-evolvablelink] is available, allowing you to manipulate the link.
69 |
70 | ```php
71 | true];
77 |
78 | $link = new EvolvableLink('payment', $href, $attributes);
79 |
80 | $newInstance = $link->withAttribute('two', 'three');
81 |
82 | var_dump(
83 | $newInstance->getAttributes()
84 | );
85 |
86 | // [
87 | // 'one' => true,
88 | // 'two' => 'three',
89 | // ];
90 | ```
91 |
92 | ## EvolvableLinkProvider
93 | The [Phalcon\Html\Link\LinkProvider][html-link-linkprovider] is used as a container of [Phalcon\Html\Link\EvolvableLink][html-link-evolvablelink] objects. You can add them in the provider and then access them as a whole or retrieve them by `rel`.
94 |
95 | ```php
96 | getLinksByRel('cite-as')
110 | );
111 |
112 | // [
113 | // Link('cite-as', 'https://test.phalcon.ld'),
114 | // ]
115 | ```
116 |
117 | ## Serializers
118 | ### Header
119 | You can use a serializer to parse the `Phalcon\Html\Link\*` objects and create the necessary headers. Phalcon comes with the [Phalcon\Html\Link\Serializer\Header][html-link-serializer-header] serializer, to help with the task of serializing links for the headers:
120 |
121 | ```php
122 | serialize([$link]);
132 | // ; rel="prefetch"';
133 |
134 |
135 | $links = [
136 | (new EvolvableLink('preload', '/1'))
137 | ->withAttribute('as', 'image')
138 | ->withAttribute('nopush', true),
139 | (new EvolvableLink('alternate', '/2'))
140 | ->withRel('next')
141 | ->withAttribute('hreflang', ['en', 'es'])
142 | ];
143 |
144 | echo $serializer->serialize([$link]);
145 | // 1>; rel="preload"; as="image"; nopush,
146 | // 2>; rel="alternate next"; hreflang="en"; hreflang="es"
147 | ;
148 | ```
149 |
150 | ### Custom
151 | You can create your own serializers for relevant links by extending the [Phalcon\Html\Link\Serializer\SerializerInterface][html-link-serializer-serializerinterface]
152 |
153 | ```php
154 | format([4560]);
53 |
54 | // USD$ 4,560.5
55 | $formatter = new MessageFormatter('en_US', 'USD$ {0, number}');
56 | echo $formatter->format([4560.50]);
57 |
58 | // ARS$ 1.250,25
59 | $formatter = new MessageFormatter('es_AR', 'ARS$ {0, number}');
60 | echo $formatter->format([1250.25]);
61 | ```
62 |
63 | Message formatting using time and date patterns:
64 |
65 | ```php
66 | format($values);
77 |
78 | // 'À 15:53:01 le 19 avr. 2015, il y avait une perturbation sur la planète 7.'
79 | $pattern = 'À {1, time} le {1, date}, il y avait une perturbation sur la planète {0, number}.';
80 | $formatter = new MessageFormatter('fr_FR', $pattern);
81 | echo $formatter->format($values);
82 | ```
83 |
84 | ## Locale-Sensitive Comparison
85 | The [Collator][collator] class provides string comparison capability with support for appropriate locale-sensitive sort orderings. Check the examples below on the usage of this class:
86 |
87 | ```php
88 | setStrength(Collator::PRIMARY);
97 |
98 | var_dump(
99 | $collator->compare('una canción', 'una cancion')
100 | );
101 |
102 | // Returns that the strings are not equal
103 | $collator->setStrength(Collator::DEFAULT_VALUE);
104 |
105 | var_dump(
106 | $collator->compare('una canción', 'una cancion')
107 | );
108 | ```
109 |
110 | ## Transliteration
111 | [Transliterator][transliterator] provides transliteration of strings:
112 |
113 | ```php
114 | transliterate($string); // garconetudiantoulecole
123 | ```
124 |
125 | [intl]: https://pecl.php.net/package/intl
126 | [intl-manual]: https://www.php.net/manual/en/intro.intl.php
127 | [intl-book]: https://www.php.net/manual/en/book.intl.php
128 | [messageformatter]: https://www.php.net/manual/en/class.messageformatter.php
129 | [collator]: https://www.php.net/manual/en/class.collator.php
130 | [transliterator]: https://www.php.net/manual/en/class.transliterator.php
131 |
--------------------------------------------------------------------------------
/docs/introduction.md:
--------------------------------------------------------------------------------
1 |
2 | # Phalcon Framework: A PHP framework built as an extension for PHP
3 |
4 | **A full-stack PHP framework delivered as a C-extension**
5 |
6 | [](https://github.com/phalcon/cphalcon/actions/workflows/main.yml)
7 |
8 | ## Mission :rocket:
9 |
10 | Our mission is to empower developers with an advanced, feature-rich tool: Phalcon. This framework is designed to facilitate the development of powerful applications with minimal server resource consumption and optimal performance.
11 |
12 | ## What is Phalcon :question:
13 |
14 | Phalcon is an open-source full-stack framework for PHP, distinguished by its unique architecture written as a C-extension. This means that it is implemented in C and directly integrated into PHP for enhanced performance.
15 |
16 | Its innovative architecture ensures that the framework is always memory-resident, providing functionality on demand without the overhead of file stats and reads typical in traditional PHP frameworks.
17 |
18 | ## Usage :memo:
19 |
20 | Phalcon is designed to be developer-friendly, and you don't need to be familiar with the C language to utilize its power. The framework's interface is exposed as PHP classes under the `Phalcon` namespace, making it accessible and easy to use.
21 |
22 | Phalcon is loosely coupled, allowing developers to use only the objects that they need as glue components based in the needs of their applications.
23 |
24 | !!! info "NOTE"
25 |
26 | The translation of the documentation is driven by enthusiasts and contributors. We invite and appreciate your participation in the translation effort. Contribute new translations or corrections via [GitHub][github_docs] for English or [Crowdin][crowdin] for other languages.
27 |
28 | You can check our [GitHub][github] project for the code and browse through these documents for usage and functionality.
29 |
30 | Since this is a community driven project, you can share your thoughts and requests for functionality you need by issuing a [New Feature Request][new-feature-request] and if you wish vote in GitHub for [existing NFRs][new-feature-request-list].
31 |
32 | Feel free to connect with us using our social media accounts:
33 |
34 |