Subscribe: Planet PHP
http://www.planet-php.org/rss/
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
>ticket  cmf  component  data  domain  function  mapper  new  public function  request  response response  response  return  symfony  ticket 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Planet PHP

Planet PHP



People blogging about PHP



 



One Year of Event Storming - thePHP.cc

Wed, 23 Aug 2017 07:00:00 +0000




Symfony CMF 2.0.0 Stable Release - Symfony CMF

Wed, 23 Aug 2017 00:00:00 +0000

Over the summer, we have been tagging the 2.0.0 releases of the Symfony CMF components and bundles. This week, we managed to wrap up the last bits and pieces and tagged 2.0.0 of all parts of the CMF.

CMF version 2 runs on PHP 5.6 and 7, and is compatible with Symfony 2.8 LTS and all maintained versions of Symfony 3. The sonata admin integration has been moved into its own separate bundle to not clutter up the bundles with an optional integration. We created a resource component inspired by puli. The tree browser bundle was rebuilt on top of the new resource infrastructure, and uses new Javascript libraries. Sonata PHPCR-ODM Admin has also been updated to use the new tree bundle and been released as version 2.0.0.

For a detailed list of changes, see the CMF 2 RC1 blogpost and the changelog of each component.

As already mentioned in the RC blogpost, we had to abandon some packages to focus our efforts. CreateBundle, MediaBundle, SearchBundle and SimpleCmsBundle are currently not maintained. If you want to help co-maintaining any of those packages, tell us in a GitHub issue or in #symfony_cmf of Symfony slack.

How to upgrade?

A lot of deprecated code was removed. Before upgrading, run your tests and check for deprecation warnings in the test log.

Each repository contains a UPGRADE-2.0.md file that should explain the breaking changes when migrating to version 2. The instructions can be incomplete at this point. If you have time to test the migration, please reach out to us on GitHub or Slack if you find inaccuracies or information is missing.

Next steps

We are happy with the current release, but there is of course always more that could be done. When Symfony 4 starts to take shape, we will have to make sure all components are compatible with it.

For CMF 2.1, there is a tentative roadmap in the CMF wiki. Another topic we discuss is whether to use a mono repository aproach or a tool to synchronize files into all our repositories, similar to the Sonata dev-kit.

If you want to get involved, comment on the github issues or join us at #symfony_cmf in the Symfony slack.




Slim and Action-Domain-Responder - Paul M. Jones

Tue, 22 Aug 2017 16:59:01 +0000

I’ve had a warm place in my heart for Slim for a long time, and especially so since recognizing the Action-Domain-Responder pattern. In this post, I’ll show how to refactor the Slim tutorial application to ADR. One nice thing about Slim (and most other HTTP user interface frameworks) is that they are already “action” oriented. That is, their routers do not presume a controller class with many action methods. Instead, they presume an action closure or a single-action invokable class. So the Action part of Action-Domain-Responder already exists for Slim. All that is needed is to pull extraneous bits out of the Actions, to more clearly separate their behaviors from Domain and the Responder behaviors. I. Let’s begin by extracting the Domain logic. In the original tutorial, the Actions use two data-source mappers directly, and embed some business logic as well. We can create a Service Layer class called TicketService and move those operations from the Actions into the Domain. Doing so gives us this class: ticket_mapper = $ticket_mapper; $this->component_mapper = $component_mapper; } public function getTickets() { return $this->ticket_mapper->getTickets(); } public function getComponents() { return $this->component_mapper->getComponents(); } public function getTicketById($ticket_id) { $ticket_id = (int) $ticket_id; return $this->ticket_mapper->getTicketById($ticket_id); } public function createTicket($data) { $component_id = (int) $data['component']; $component = $this->component_mapper->getComponentById($component_id); $ticket_data = []; $ticket_data['title'] = filter_var( $data['title'], FILTER_SANITIZE_STRING ); $ticket_data['description'] = filter_var( $data['description'], FILTER_SANITIZE_STRING ); $ticket_data['component'] = $component->getName(); $ticket = new TicketEntity($ticket_data); $this->ticket_mapper->save($ticket); return $ticket; } } ?> We create a container object for it in index.php like so: And now the Actions can use the TicketService instead of performing domain logic directly: get('/tickets', function (Request $request, Response $response) { $this->logger->addInfo("Ticket list"); $tickets = $this->ticket_service->getTickets(); $response = $this->view->render( $response, "tickets.phtml", ["tickets" => $tickets, "router" => $this->router] ); return $response; }); $app->get('/ticket/new', function (Request $request, Response $response) { $components = $this->ticket_service->getComponents(); $response = $this->view->render( $response, "ticketadd.phtml", ["components" => $components] ); return $response; }); $app->post('/ticket/new', function (Request $request, Response $response) { $data = $request->getParsedBody(); $this->ticket_service->createTicket($data); $response = $response->withRedirect("/tickets"); return $response; }); $app->get('/ticket/{id}', function (Request $request, Response $response, $args) { $ticket = $this->ticket_service->getTicketById($args['id']); $response = $this->view->render( $response, "ticketdetail.phtml", ["ticket" => $ticket] ); return $response; })->setName('ticket-detail'); ?> One benefit here is that we can now test the domain activities separately from the actions. We can begin to do something more like integration testing, eve[...]



Are Bitwise Operators Still Relevant in Modern PHP? - SitePoint PHP

Mon, 21 Aug 2017 16:00:53 +0000

Many of you probably scratched your heads reading this title. "Bitwhat?" In this article, we'll look at what bitwise operators are, and whether or not their use is still relevant in this modern age of computing. [...]



ZendCon 2017 - Zeev Suraski

Mon, 21 Aug 2017 11:01:00 +0000

First of all, a big Thank You to everyone who sent their interesting, inspiring or peculiar PHP stories - I can't wait to share them with the world!  And if you still have an interesting PHP-related story to share - how it helped affect your life, how it helped you change other people's lives, how it helped you meet your spouse or how you've bumped into it in an unexpected location - there's still time to share!

Now, for those of you who haven't paying attention - we're approaching the end of summer and ZendCon 2017 is right around the corner!  If you want to be there - and you do - Early Bird is ending in just 10 days.  Not to mention that if you refer someone - you get a chance to win one of those:


To be clear, we're talking about the giant elePHPant, not my daughter!  Also note that it'll be the ZendCon 2017 edition, which may not necessarily be red, but I can say will be completely awesome.

See you there!





Why MVC doesn’t fit the web - Paul M. Jones

Fri, 18 Aug 2017 14:49:07 +0000

[MVC is] a particular way to break up the responsibilities of parts of a graphical user interface application. One of the prototypical examples is a CAD application: models are the objects being drawn, in the abstract: models of mechanical parts, architectural elevations, whatever the subject of the particular application and use is. The “Views” are windows, rendering a particular view of that object. There might be several views of a three-dimensional part from different angles while the user is working. What’s left is the controller, which is a central place to collect actions the user is performing: key input, the mouse clicks, commands entered.

The responsibility goes something like “controller updates model, model signals that it’s been updated, view re-renders”.

This leaves the model relatively unencumbered by the design of whatever system it’s being displayed on, and lets the part of the software revolving around the concepts the model involves stay relatively pure in that domain. Measurements of parts in millimeters, not pixels; cylinders and cogs, rather than lines and z-buffers for display.

The View stays unidirectional: it gets the signal to update, it reads the state from the model and displays the updated view.

The controller even is pretty disciplined and takes input and makes it into definite commands and updates to the models.

Now if you’re wondering how this fits into a web server, you’re probably wondering the same thing I wondered for a long time. The pattern doesn’t fit.

Read the rest at Why MVC doesn’t fit the web.




Refactoring Done Right - Nomad PHP

Fri, 18 Aug 2017 04:01:43 +0000

November 2017 - US
Presented By

Brandon Savage
November 16, 2017
20:00 CST

The post Refactoring Done Right appeared first on Nomad PHP.




API Tips From the Frontline - Nomad PHP

Fri, 18 Aug 2017 04:01:13 +0000

November 2017 - EU
Presented By

Anna Filina
November 16, 2017
20:00 CET

The post API Tips From the Frontline appeared first on Nomad PHP.




How to Master Your API Workflow with Postman - SitePoint PHP

Thu, 17 Aug 2017 16:00:26 +0000

Building good APIs is hard, and anyone who had the chance to do so can relate to this. A project can easily grow to become a mess. One can keep trying to adopt an approach to make it more enjoyable, like trying a documentation-first workflow, but something always feels clumsy. I was trying out Postman lately, a tool we've briefly covered before, and I discovered that they're doing a great job by providing an integrated environment for different components of an API, like authorization, testing, documentation, versioning, etc. In this article, we're going to walk through the different features that Postman provides and how we can organize them to make our API workflow less painful. Making Requests The first step to discovering Postman is making a simple API request and seeing the response. From the screenshot above we can see that the view incorporates different elements. The top bar contains the request method (in this case GET), and right next to it we specify the endpoint to make the request to. If the request has some params we can specify them by clicking the Params button, which will open a table for entering them. When ready, we can click the send button to initiate the request. The next section contains five tabs: Authorization: Specifies how to authorize the request. Like Basic Auth, OAuth2, etc. Headers: Any header that should be sent with the request. Like content-type, Authorization, etc. Body: Request body for request types like Post, PUT, etc. Pre-request Script: JS code to be executed before performing the request. (More about this later) Tests: JS code to validate the response payload. The bottom section contains all the details about the response (status, time and size). The four tabs are self explanatory, except for Tests which contains the tests result if we have any (more about this later). Authorization Postman supports all types of authorization, as we saw above. We're going to focus on token authorization set via header. You can read more about authorization here. The header format that Postman will use is: Authorization: Bearer Now, we'll go ahead and get a token we can use for our future requests. I'm testing on an in-development application of mine, but you can use any application you have lying around, or set one up quickly with Laravel as described here. Not familiar with Laravel? Try our premium course - it's a comprehensive introduction, and you'll get the upcoming newer version of it automatically if you grab it in its current iteration! At this point, we have a token to be used for querying data from the API as an authenticated user. However, copying and pasting the token for every request is tedious! Environment Variables This nice feature alleviates the pain of copy/paste and groups our variables in one place. An environment is an execution context: we may have a local environment, testing, staging, etc. Postman has different scopes for variables: Global Environment Local Data The global variables are available everywhere, separately from the selected environment. You can read more in the documentation. We need at least three variables for now: domain: current active subdomain company1, company2, etc. url: our app URL. token: Token for future authentication. Truncated by Planet PHP, read more at the original (another 932 bytes)[...]



PHP 7.2.0 Beta 3 Released - PHP: Hypertext Preprocessor

Thu, 17 Aug 2017 00:00:00 +0000

The PHP development team announces the immediate availability of PHP 7.2.0 Beta 3. This release is the third and final beta for 7.2.0. All users of PHP are encouraged to test this version carefully, and report any bugs and incompatibilities in the bug tracking system. THIS IS A DEVELOPMENT PREVIEW - DO NOT USE IT IN PRODUCTION! For more information on the new features and other changes, you can read the NEWS file, or the UPGRADING file for a complete list of upgrading notes. These files can also be found in the release archive. For source downloads of PHP 7.2.0 Beta 3 please visit the download page, Windows sources and binaries can be found at windows.php.net/qa/. The first Relase Candidate will be released on the 31th of August. You can also read the full list of planned releases on our wiki. Thank you for helping us make PHP better.