PatrickL

Experience

2,620

0 Best Reply Awards

  • Member Since 5 Months Ago
  • 14 Lessons Completed
  • 0 Favorites

6th October, 2018

PatrickL started a new conversation Error On Laravel Entrust When Running Entrust:migration • 1 week ago

I keep getting this error when running entrust:migration on a new Laravel install.

ReflectionException : Method Zizaco\Entrust\MigrationCommand::handle() does not exist

Not sure what is going on. Any advice?

19th September, 2018

PatrickL left a reply on Stripe API And Widholding Funds • 3 weeks ago

@AlbertLabarento Alright. That makes sense. Would it be a good idea to use a separate stripe account to handle this, and use my primary one to collect fees (revenue source)? Or is it okay to clump them into one?

PatrickL left a reply on Stripe API And Widholding Funds • 3 weeks ago

@shez1983 I have it set up so that both the buyer and seller have to agree that the transaction is completed. This can be initiated by either party. Additionally, there are other measures in place to deal with users that try to abuse the system.

Am I going to need two separate Stripe Accounts to do this though? Like, one to collect transaction fees and the other to hold these funds?

PatrickL started a new conversation Stripe API And Widholding Funds • 3 weeks ago

I have a question related to the Stripe API for PHP. What I am building is a platform marketplace, quite similar to an e-commerce platform using the Stripe Connect service as a payments provider. One of the requirements for this platform is the application widholds the funds of a customer’s purchase until the seller fulfills said purchase. This is mostly to protect the platform from fraudulant activity.

Is there a way to implement this kind of mechanism or can Stripe handle this automatically?

18th September, 2018

17th September, 2018

PatrickL started a new conversation Converting A A Float Representation Of A Date To Carbon Object • 4 weeks ago

One of the components of my application needs to convert a date (in float format), that it receives from another component, back into a Carbon object for processing and other stuff. But, I am uncertain how to go about converting it.

My app's first component returns a float (using Carbon's valueOf() method). The reason I chose this approach is to make it ideal to pass into javascript. Bur, other components of the application's backend also need to receive and process such dates.

So, how would I go about converting a date in float format, (i.e. float(1349479571124)) to a Carbon object, or, at the very least, a datetime string that I can parse into a Carbon object.

Thanks.

7th September, 2018

PatrickL left a reply on Address Validation In PHP And Laravel • 1 month ago

@Cronix Alright. I’ll try it out. But, if I end up having to spend money, I might as well just use the Geocoder I am using on my other component lol

PatrickL left a reply on Address Validation In PHP And Laravel • 1 month ago

@Cronix Preferrably world wide. My plan is to store all user data, including user addresses (this component) in one component. And then have another component dedicated to geocoding and doing stuff with this data.

PatrickL started a new conversation Address Validation In PHP And Laravel • 1 month ago

Are there any recommended packages for validating addresses? I have my app split across several projects, each their own bounded context. In my User Bounded Context, I need to validate the address entered by the user to be used in the application. I just need to make sure the address exists. Nothing more (at least for this component).

Any advice.

1st September, 2018

PatrickL left a reply on Multiple Ids In Route • 1 month ago

The variables in your route need to be unique. Once that’s done, in your controller function, include arguments matching the order of the variables in your route. They will then be injected automatically.

PatrickL left a reply on What Front End Framework Is Use In Laracasts ? • 1 month ago

Vue is what is included in Laravel. But you are free to use others as well, like React.

PatrickL started a new conversation File Not Found Error In Use Statement In Namespaced File • 1 month ago

So, my folder structure looks like this:

Javelin (Project name)
- src
- - Utils
- - - ID
- - - ID.php (has the namespace "Utils")
- - - IDInterface.php (has namespace "Utils")
- - Value
- - - ValueInterface.php (has namespace "Domain\Value")
- - - Value.php (has namespace "Domaini\Value")
- tests
- - IDTest.php
- vendor
- // other stuff

On my IDTest, when I run it with PHPUnit, I get the following Error:

PHP Fatal error:  Interface 'Javelin\Value\ValueInterface' not found in path/to/Documents/projects/Javelin/src/Value/Value.php on line 23

The error is referring to Value.php, which has the following definition.

<?php

namespace Value;

use Javelin\Value\ValueInterface;
use Javelin\Exception\IllegalStateChangeException;

/**--------------------------------------------------------------------------
|
|   Value
|
-----------------------------------------------------------------------------
|
|   A Value represents a Value Object. A Value Object is an object that 
|   represents a descriptive aspect of a domain with no conceptual 
|   identity. Value Objects are instanciated to implement design elements
|   in which we only care about what they are. 
|
-----------------------------------------------------------------------------
*/


abstract class Value implements ValueInterface // This is line 23
{
    // definition here
}

This leads me to believe there is something wrong with how I namespaced my file. But, it all seems correct from what I can tell. For reference, ValueInterface.php looks like this:

<?php

namespace Value; 

/**--------------------------------------------------------------------------
|
|   ValueInterface
|
-----------------------------------------------------------------------------
|
|   A Value represents a Value Object. A Value Object is an object that 
|   represents a descriptive aspect of a domain with no conceptual 
|   identity. Value Objects are instanciated to implement design elements
|   in which we only care about what they are. 
|
-----------------------------------------------------------------------------
*/


interface ValueInterface{}

And, IDTest.php looks something like this:


use PHPUnit\Framework\TestCase;
use Javelin\Utils\ID\ID;

/**===========================
||          IDTest
==============================
*/

class IDTest extends TestCase
{
    public function testConstructFromString()
    {
        $id = new ID("foo");
        $this->assertSame("foo", $id->value());
    }
}

?>

What am I doing wrong?

26th August, 2018

PatrickL left a reply on Interface Not Found Error In PHP • 1 month ago

@crnkovic Oh, so I should have used

use Javelin\Domain\ValueInterface;

instead?

How does the autoloading work with regards to namespaces and directory structure?

In a test for my ID class in the same project, it throws an error when I do

use Javelin\Utils\ID;

On a class located in src/Utils/ID/ID.php with a namespace of Utils. But, doing this instead would work just find:

use Javelin\Utils\ID\ID;

even though the namespace of the files should just be Utils. I think this might be the cause of my mix up. Lol

Thanks for the help.

PatrickL started a new conversation Interface Not Found Error In PHP • 1 month ago

Hey, so, I am getting this error when running my PHP script.

PHP Fatal error:  Interface 'Javelin\Value\ValueInterface' not found in /Users/PatrickL/Documents/Developer/Javelin/src/Value/Value.php on line 23

It is referring to the following file.

<?php

namespace Domain;

use Javelin\Value\ValueInterface;
use Javelin\Exceptions\IllegalConversionException;

/**--------------------------------------------------------------------------
|
|   Value
|
-----------------------------------------------------------------------------
|
|   A Value represents a Value Object. A Value Object is an object that 
|   represents a descriptive aspect of a domain with no conceptual 
|   identity. Value Objects are instanciated to implement design elements
|   in which we only care about what they are. 
|
-----------------------------------------------------------------------------
*/


abstract class Value implements ValueInterface
{
    // Class definition here.
}

More specifically, line 23 is the following:

abstract class Value implements ValueInterface

For reference, ValueInterface (the interface it cannot find) looks like this.

<?php

namespace Domain; 

/**--------------------------------------------------------------------------
|
|   Value
|
-----------------------------------------------------------------------------
|
|   A Value represents a Value Object. A Value Object is an object that 
|   represents a descriptive aspect of a domain with no conceptual 
|   identity. Value Objects are instanciated to implement design elements
|   in which we only care about what they are. 
|
-----------------------------------------------------------------------------
*/


interface ValueInterface
{
    /**
    * equals() determines if the object is equal to the target
    * @param mixed
    * @return bool
    */

    public function equals($target): bool;
}

?>

And finally, directory structure looks like this:

Javelin
- src
- - Entity
- - Value
- - - Value.php
- - - ValueInterface.php
- <other files and folders>

Any idea on what the issue is? I have a feeling I am not understanding something about namespaces and automatic includes. But, what do you all think?

Thanks for the help.

24th August, 2018

PatrickL started a new conversation Adding Laravel Generator Artisan Commands To Custom Library • 1 month ago

Hey,

I recently made a kind of skeleton library for domain-driven design elements (Entities, Value Objects, Domain Services, etc...). So, what I want to do is include some laravel artisan commands to make generating these templates easier. For example, I want to have a command like the following:

php artisan make:aggregate Customer 

which would then generate a file in the directory Project/App/Aggregates/Customer/Customer.php, containing the template for the Aggregate class, which I already have defined in my Library.

Likewise, I would have a command like:

php artisan make:value Name --path="app/Aggregates/Customer"

Would create a file called Project/app/Aggregates/Customer/Name.php containing the predefined template file for a Value Object that I have previously defined.

I want to be able to include this in my future projects via composer. How would I go about doing this?

Thank you for your help.

12th August, 2018

PatrickL left a reply on JSON API Format And Laravel • 2 months ago

@bobbybouwmann Thanks. This helps a lot.

Would I also be able to check for media type parameters using this same fashion?

Thanks for the help.

10th August, 2018

PatrickL left a reply on Instantiating Objects • 2 months ago

I believe what you need to do is require the autoload file.

require_once(__DIR__ . "/autoloader.php");

// Class instantiation here

PatrickL started a new conversation JSON API Format And Laravel • 2 months ago

I am making an API in Laravel that is compliant with the JSON API standard, which can be fund here: http://jsonapi.org/format/

I have two questions though. Both of them have to do with the Server responsibilities section of the spec.

The first question has to do with the following requirement:

"Servers MUST respond with a 415 Unsupported Media Type status code if a request specifies the header Content-Type: application/vnd.api+json with any media type parameters."

My question is how do I check request headers for media types and if they have parameters. (This check will be done using middleware).

My second question is regarding whether or not there is a way to modify responses automatically to include the required metadata in JSON API? Like, instead of adding the necessary media type (Content-Type: application/vnd.api+json) in each and every response, can I just define it in one place and have it automatically added in all my application's API responses? This is not really a requirement. It would just make things easier to modify or update in the future.

Thanks.

PatrickL left a reply on Trigger Notification On Bulk Insert • 2 months ago

To bulk insert, you could probably use Database Transactions.


DB::transaction(function() {
    // your insert code here
    
    foreach($appointments as $appointment){
        event(new AppointmentNew($appointment);
    }
}, 5);

Then you can just create the appropriate listener to actually send the notification. I assume you mean a notification sent to the end user when you say "notification".

Also, be sure to make the event queue.

Hope this helps :)

5th August, 2018

PatrickL left a reply on Are There Any Widely Accepted Standards For JSON APIs? • 2 months ago

@tykus Ah. Okay. Thanks

PatrickL started a new conversation Are There Any Widely Accepted Standards For JSON APIs? • 2 months ago

I’m building a Laravel App backend, which is intended to provide data to an Angular Front End and, eventually, a Flutter mobile app. As I’m designing this, I start to wonder if there are any widely accepted standards for formatting JSON API responses.

Is there a widely accepted standard? Or, is it more of a do it your own way thing?

Thanks.

4th August, 2018

PatrickL started a new conversation Checking Scopes In Microservices Using Passport • 2 months ago

I have a Microservice-based application I am building. And, I decided to use Passport as an OAuth2 server on my Accounts service. The question I am wondering is how do I verify token scopes within other services (suppose a Posts Service)? Do I need to have Passport installed in every Microservice?

Or is there another way?

Appreciate the help. :)

3rd August, 2018

PatrickL started a new conversation Question About OAuth2 And Microservices • 2 months ago

I’m designing an e-Commerce application using a Microservice Architecture (This is my first time building a Microservice based application). After some research, I discover that OAuth is the ideal way of securing microservices.

I find this package that I can use to implement an OAuth Auth server. https://github.com/dusterio/lumen-passport

The thing I’m wondering now has to do with scopes. As shown in this great lecture describing how OAuth2 works: https://youtu.be/996OiexHze0

The Auth Server has a list of pre-defined scopes a client can choose from. Each Microservice then checks the access token they receive with the request to see if they have the right scope (permissions) to perform tasks with the resource.

So, my question is what is the best way for the distinctive microservices to verify scopes?

Do I have have to query the Auth server? Do I just have a list of scopes supported by each Microservice as an array of constants? Or what?

Like, suppose I have an Accounts Microservice (which has the OAuth Auth server) and an Orders Microservice. And the the client application has gone through the code flow and is now requesting to the Order service that an order be placed.

How does the Order service verify that the client has the right scope?

Thanks for the help.

31st July, 2018

PatrickL left a reply on Misunderstanding Of Composer Autoloading • 2 months ago

@lostdreamer_nl Fixed. Thank you for the help :)

PatrickL started a new conversation Misunderstanding Of Composer Autoloading • 2 months ago

Hey,

I am writing some base components for a Domain-Driven Design library that I intend to use in future projects. But, I think I have some misunderstanding regarding how composer’s psr-4 autoloading works.

So, I have a PHPUnit test case that looks something like this:

3rd June, 2018

PatrickL left a reply on When Exactly Do I Use A Service Provider? • 4 months ago

Ah okay. Thanks guys :)

2nd June, 2018

PatrickL left a reply on When Exactly Do I Use A Service Provider? • 4 months ago

@isaackearl Ah. Okay. I think it makes sense now. So, a Service Provider is used to bind parts of an application’s abstract functionality to a specific implementation so that it can easily be replaced. For example, if I had a payment processing service interface, I’d register that interface to map to a specific implementation (say, Stripe) so that I can just type hint the interface and get the chosen implementation. This is so that, in the event I choose to use a different implementation (say, Square) I can simply update the provider with the new implementation without having to modify my code anywhere else.

Is that accurate?

1st June, 2018

PatrickL left a reply on When Exactly Do I Use A Service Provider? • 4 months ago

@martinbean Okay. I guess that kind of makes sense. So, just to clarify, a service in this context depends on my application. Like, going back to my DDD reference, a domain service would be a good candidate to build a Service Provider around? Suppose in a store application where I have a Product and CustomerAccount Domain and a BuyProduct Domain Service. The BuyProduct domain service would be a good candidate for a Service Provider?

PatrickL left a reply on When Exactly Do I Use A Service Provider? • 4 months ago

@isaackearl Can you clarify what you mean by ”which I think makes sense to be wrapped up in a service”?

PatrickL started a new conversation When Exactly Do I Use A Service Provider? • 4 months ago

The docs explain that it is used to register things... Which is kind of vague. Can you help clear up when exactly it would be ideal to use a Service Provider?

Based on the online examples I have seen from other discussions on laracasts that ponder the same question, Service Providers are equivalent to Domain Driven Design’s concept of Model Factories which are abstractions for creating complex entities, aggregates, and value objects (complex as in the creation of an object has a lot of dependencies to other objects). Is this an accurate way to look at Service Providers, as far as determining when to use them?

Or am I missing something completely?

19th May, 2018

PatrickL started a new conversation Design Considerations For Horizontal Scaling • 4 months ago

Okay. So, I have this monolith travel app I made a few months ago. It is the first Laravel app I made. As in, it's tightly coupled. Suppose I wanted to deploy this application. Would it be worth going through the haste of decoupling that application so it can scale horizontally?

In my later projects, I design them with DDD principles. Usually, I’d write a library that contains the main logic of my application (the domain layer) without a framework, writing specific interfaces for tasks that need to be delegated to larval or whatever I’m using (the Application Service Layer). Then, on Laravel, I implement the framework specific part (Architecture layer) like data persistence, logging, etc... And when designing like this, I can more easily prepare for horizontal scaling.

With this old app, however, all the logic are in the controllers.

Any advice?

18th May, 2018

PatrickL left a reply on General Workflow From Idea To V1 • 4 months ago

I’m mostly a self-taught dev. What I usually do is the following:

  1. Write the description of the application: what is it, who will use it, how will it add value, etc...
  2. List and prioritize features: List and prioritize the features of your application.
  3. Start drawing: sketch out the important concepts of your applications. These are equivalent to the domain models in Domain Driven Design. These are the different things in your application and how they interact with each other.
  4. Start coding: higher priority requirements first.
  5. Test
  6. Refine
  7. Repeat

17th May, 2018

PatrickL left a reply on Page Not Found On Route Invocation • 4 months ago

OOps. Looks like I messed up in posting my code. Let me fix that.

PatrickL started a new conversation Page Not Found On Route Invocation • 4 months ago

I seem to be doing something wrong here. Everything was working fine until now. I am building a web app intended to be a sort of game forum. There, "Communities" represent a collection of posts dedicated to a particular video game title. The controller for that looks this.

'''php

15th May, 2018

PatrickL left a reply on Messages For Communicating Between Microservices Using Laravel • 5 months ago

Thanks everyone :)

14th May, 2018

PatrickL left a reply on Messages For Communicating Between Microservices Using Laravel • 5 months ago

@topvillas It’s mostly for learning purposes. And, to make it easier to scale out the application. But primarily the former. :)

PatrickL started a new conversation Messages For Communicating Between Microservices Using Laravel • 5 months ago

Sorry if this sounds kind of bookish. But, this is the first time I’m going to do something like this in a project.

So, in a project I'm currently planning, I am building a microservice-driven e-Commerce web application. As I’m doing my research, I learned there is a need for messaging between service applications (bounded contexts in Domain Driven Design terms). The resources I’ve been reading mention that there are ”messaging frameworks” available to help in fulfilling such requirements.

I was wondering if Laravel supported this functionality, as I am considering using laravel for my architectural layer. Or is there another library that is best suited for this?

Thanks.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.