-
-
Notifications
You must be signed in to change notification settings - Fork 101
Read the Code
At its core screeenly is a Laravel application. In a typical Laravel installation, the logic and all classes of the application are stored in the /app
folder.
In screeenly I've decieded to split the actual application code from the Laravel "core" code. You find the code related to screeenly in /modules/Screeenly
.
This folder contains as already said the core of the application. In this section I would like to point out what each subfolder contains and how its content is used throughout the application.
Contracts contains interfaces which are bound in Laravels IoC Container. There's for example a CanCaptureScreenshot
Interface. This interface is implemented by the PhantomJsBrowser
class.
If I would like to use a different technology to capture screenshots I could create a new class which implements this interface.
Then I simply would have to switch the binding in the ScreeenlyServiceProvider
.
Entities contains simple PHP Objects / Classes with the only purpose to improve and simplify the code a bit.
Guards contains custom Authentication Guards. You can read more about Guards here.
The ScreeenlyTokenGuard
is responsible for the authentication of a user during an API call.
The class reads the provided ApiKey and checks if it's a valid key. The corresponding user is than added to the current Request Object.
The Http folder is very similar to the default Http folder found in every Laravel application. It contains Controllers
, Middlewares
, Requests
and the routes-files.
Models contains the Eloquent Models of the application. The application is thankfully quite small and doesn't have many models.
The Providers folder contains our ScreeenlyServiceProvider
. This class registers our custom View Namespace, binds our CanCaptureScreenshot
Interface to a an Implementation and registers our ScreeenlyTokenGuard
.
In Resources you can find all Blade Views used by the application.
The Services folder contains the core logic how we pass width, height and other parameters from PHP to PhantomJs.