Notifications trait in Sails.js - similar to Laravel? - sails.js

I'm coming from Laravel, moving to Sails.js, I was wondering how to handle notifications? Laravel has this - https://laravel.com/docs/5.7/notifications
A notifiable trait which we can add to the model. And then do Model->notify(NotificationClass).
I went through the Sails 1.0 docs but can't find anything on notifications. Is there some information on this?

Related

What is the best way to define notification endpoint?

I’m defining a new schema for a restful api which can get and add notifications. An existing endpoint notifications is already used for something else unfortunately, so I have two ideas on what to do instead.
/NotificationAPI/1.0.0/notification_endpoints
or
/NotificationAPI/1.0.0/notification_configurations
Which one do you find makes more sense?

How to use a RESTful API as ORM in CakePHP 3?

In CakePHP 1.x/2.x, it was fairly simple to have a model's data come from a REST API (as opposed to a relational database), by defining a custom datasource. (Neil Crookes' CakePHP-ReST-DataSource-Plugin was a great place to start.) Slap your custom datasource on your model, and you're making calls like $this->MyModel->find() just like you were querying a MySQL table called my_models.
I'm trying to figure out how to achieve this same effect under CakePHP 3.0. That is, make find()/save()/set()/get() calls against a Table/Entity driven by a REST API.
Since 3.0's ORM system is A) fairly new, and B) a rather large departure from the old way of doing things, I haven't found any information about how to do something like this. In fact, based on this SlideShare from
José Lorenzo Rodríguez, it sounds like it might not be possible.
This means:
not going to connect to stuff that is not a relational database.
Is there someone more familiar with CakePHP 3.0 that could clarify if what I'm looking for is possible under the new ORM system? If so, could you explain what classes you'd have to extend or implement to achieve such a function?
If you want to create a complete adapter for your Rest datasource using the interfaces and classes provided by CakePHP, take a look at this early experiment fro the CakePHP team on making a datasource for Elastic Search.
Elastic Search uses a Rest API and this plugin attempts to create classes that work similar to the CakePHP ORM:
https://github.com/cakephp/elastic-search
What it implements is basically the following:
A Type class that implements the RepositoryInterface
A Document class that implements the EntityInterface
A Query class that can be used as a collection object and has similar methods
In the near future it will provide a paginator adaptor and a form helper adaptor.
If you want to save yourself this trouble, because there for you there is little value in exposing your datasource as something ORM-like, you can just use guzzle or any similar library to interface with your API and use it as a service instead of a full-blown layer.
In the year since I asked this question, UseMuffin has built a Webservice plugin that purports to "bring [...] the power of the CakePHP ORM to your favourite webservices." This sounds like exactly what I wanted at the time.

laravel 4 restful controllers manually

In the laravel docs they have explained using resourceful controllers for using REST and using verbs in the methods of the controllers.
I have manually listed all my routes like this:
Route::get('users/{id}/friends', 'UsersController#friends');
I am not using any resource just the method and the uri.
How can I make this restful? Or is it restful already? Then how do I call the methods in a RESTful manner? I am confused
REST is nothing more than a convention on how data should transfer in the web. If you want to be all nitpicky about it check this out: http://en.wikipedia.org/wiki/Representational_state_transfer#Architectural_constraints
As for laravel, when you generate a controller via the CLI like so:
php artisan controller:make UsersController
Laravel automatically creates the boiler plate for the various actions you need to be handling (create, store, destroy, update and so on.) and then you can set-up your routes. Of course you wont need all for most controllers.
Here's a helpful set of links from Phillip Brown's blog:
http://culttt.com/2013/07/01/setting-up-your-first-laravel-4-controller/
http://culttt.com/2013/08/12/building-out-restful-controller-methods-in-laravel-4/
If you want to make it RESTful, the simplest way in laravel is to do Route::resource('user', 'UserController), which automatically gives you the routes shown on the laravel web page.
However, if you are trying to look up the friends RESTfully you would want to make a /friends/ resource, and then register it as Route::resource('friends', 'FriendController'). For more on the relationships/friends side of things I would suggest reading this question from 2011, while not laravel specific, it does answer questions about REST.

play framework app authentication, user management

Following the Book App example in play 2 for scala, I now have a basic working app.
What I want now is to add some features like
User registration
User authenetication to access some pages
What is the best way to do it in play for scala? Should I manage it by my own? is there a plugin for that?
Note: I'm the maintainer of Silhouette.
I can suggest you Silhouette which is a core only fork of Secure Social with the intention to built a more customizable, non-blocking and well tested implementation.
For the first stable version there are only two open issues which must be resolved. And these issues are only future requests. There are no API changes planed. The documentation must be improved and a sample application is started. The unit tests are also a good starting point.
If you plan to follow the authentication flow as stated by Secure Social then stick with it. It exists since more than two years and it is well tested by many companies. Otherwise take a look at Silhouette.
You have two options:
Secure Social (http://securesocial.ws/)
But it has unusual registration flow, where the user have to enter your email first, and receive link to registration form.
However, there is a pull request that address this issue (https://github.com/jaliss/securesocial/pull/260)
Play Authenticate
It doesn't support Scala out of the box. But there is a workaround created by me here: https://github.com/joscha/play-authenticate/issues/92
Both of them requires you to write the interface layer to database. An important drawback in both of them, is that you won't be able to make use of reactive database drivers like Reactive Mongo. they assume that you will return the results immediately, not a Future of the result.
There is a securesocial plugin (http://securesocial.ws). Covers most common authentication methods, has registration stuff. I found it very usefull.
The drawback is it's documentation. If you want to do something a bit differ from the simplest scenarios - be prepared to read through the source code.

Does there exist a PHP event observer framework

I'm looking to create a re-distributable PHP script and provide the ability to extend the application with plugins. The basic architecture should work just like magento.
Is there a PHP event / observer framework available ?
I would expect each framework to handle those events in their unique way. I've implemented observer / events through object-level callback hooks which can be multi-purpose and higher performance than the Spl Implementation.