MickBee

Experience

3,570

0 Best Reply Awards

  • Member Since 2 Months Ago
  • 27 Lessons Completed
  • 0 Favorites

10th October, 2018

MickBee started a new conversation PHP-VCR • 5 days ago

Hi,

We have just been discussing mocking calls to external APIs.

One way of doing this, is using php-vcr (https://laracasts.com/lessons/testing-http-requests).

This video looks a little old (2014).

Is this still the recommended way?

Cheers,

Mick

2nd October, 2018

MickBee started a new conversation Include External CSS And JS In Single Page Component. • 1 week ago

How should I be doing this?

I only want these files to be loaded, when the component is loaded.

19th September, 2018

MickBee left a reply on When To Break REST. • 3 weeks ago

Nice one, that is an interesting way of doing things. I'm not sure that I want to go that far, I like just having a controller for each model. I think this makes it easier to find code if you are not familiar with the application.

Having said that, I do like his first rule: Nested resource = new controller.

Mick

MickBee started a new conversation When To Break REST. • 3 weeks ago

Hi,

I am trying to use REST as much as possible. When is it acceptable to create your own route names?

I generally feel that for standard CRUD actions REST can used but for additional actions you need to create your own route names?

What does everyone else do?

Mick

10th September, 2018

MickBee left a reply on Testing That A Guzzle Call Is Made In An Event Listener. • 1 month ago

I'm thinking about this a bit differently now. I am doing it in two ways:

1, test that the event listener is fired. 2, test the Guzzle post response separately.

Mick

MickBee started a new conversation Testing That A Guzzle Call Is Made In An Event Listener. • 1 month ago

Hi,

I have an event listener that fires when a new model is created.

In this listener, a Guzzle POST is made (internal API which returns JSON).

How can I confirm in a test, that this call is being made and getting the correct response?

Thanks,

Mick

6th September, 2018

MickBee left a reply on Ajax Table Editing • 1 month ago

The Editor component does the editing:

https://editor.datatables.net/

I agree, it is difficult because there are many ways to do it, I think it is easier to do the editing on a separate page (or modal).

Mick

MickBee left a reply on Connection Second DB • 1 month ago

I can't really see what the problem is but this is how I have achieved this:

In database.php, make sure your have the database connection defined:

 'mysqlProductsDB' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST_PRODUCTS', 'localhost'),
            'database'  => env('DB_DATABASE_PRODUCTS', 'forge'),
            'username'  => env('DB_USERNAME_PRODUCTS', 'forge'),
            'password'  => env('DB_PASSWORD_PRODUCTS', ''),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],


Then in your model. you just need:

protected $connection = 'mysqlProductsDB';

Does that not work?

Mick

MickBee left a reply on Ajax Table Editing • 1 month ago

Can I suggest cheating instead: https://datatables.net/

15th August, 2018

MickBee left a reply on Lumen API Token Authentication • 2 months ago

Thanks @salmon

"Can the existing API handle authentication for you and then make all API calls to the new Lumen API?"

The existing application is not an API, it is a full Laravel application, so yes it can handle the auth.

"If you don't need the users to interact with the new Lumen API, you can get away with configuring the new Lumen API so that it only accepts calls from your current api"

Users do not interact with the API, only the application does.

So, yes, configuring the Lumen API, to only accept calls from authenticated users sounds perfect. Where do I start with that?

MickBee left a reply on Lumen API Token Authentication • 2 months ago

Yes @salmon we have an existing Laravel web application which users log into.

We are now developing a Lumen api, the same set of users will use the api.

Thanks,

Mick

MickBee started a new conversation Lumen API Token Authentication • 2 months ago

Hi,

I am just looking at securing me new API, it is internal, so we are just using a token in the headers.

I was reading this: http://www.php-dev-zone.com/2018/02/lumen-rest-api-authentication.html

This suggests that the API has access to a users table, is that correct? Should it have its own users table? Or connect to the one belonging to the application?

Cheers,

Mick

14th August, 2018

MickBee left a reply on API Resources In Lumen • 2 months ago

It looks like they are working, Lumen just doesn't have the make commands.

Mick

MickBee started a new conversation API Resources In Lumen • 2 months ago

Hi,

I just noticed that API Resources (https://laravel.com/docs/5.6/eloquent-resources) are not in Lumen. I would have thought that this is the place where they would have been needed most (instead of using Fractal)?

How is everyone else transforming the data, in their Lumen APIs?

Thanks,

Mick

MickBee left a reply on How To Use Sqlite When Testing Lumen. • 2 months ago

Yes, that has sorted it. If anyone else gets this, you need to set the default configuration file on the PHP->Test Frameworks page.

MickBee left a reply on How To Use Sqlite When Testing Lumen. • 2 months ago

@tykus you are a genius, yes phpUnit.xml is used when I run from the command line.

I think that this means that my configuration is wrong in PHPStorm (this is where I am executing the tests from).

MickBee left a reply on How To Use Sqlite When Testing Lumen. • 2 months ago

Still the same :-(.

MickBee left a reply on How To Use Sqlite When Testing Lumen. • 2 months ago

@tykus do you have a database.php file or a config directory?

MickBee left a reply on How To Use Sqlite When Testing Lumen. • 2 months ago

Once again @crnkovic thanks for your helpful contribution. If it is that easy, why not post one of these links here?

@tykus thanks for looking, this is exactly the same as mine and it still resets my mySQL database, I wonder if something is wrong somewhere else.

13th August, 2018

MickBee left a reply on How To Use Sqlite When Testing Lumen. • 2 months ago

Thanks @tykus, I appreciate your help.

MickBee left a reply on How To Use Sqlite When Testing Lumen. • 2 months ago

Still doing the same, I now have this:

 <php>
        <env name="APP_ENV" value="testing"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="QUEUE_DRIVER" value="sync"/>
        <env name="DB_CONNECTION" value="testing" />
   </php>

MickBee left a reply on How To Use Sqlite When Testing Lumen. • 2 months ago

@tykus I tried that first and it isn't working (my MySQL database gets reset, so I assume that it is connecting to that)

@crnkovic thankyou for your valuable input.

MickBee started a new conversation How To Use Sqlite When Testing Lumen. • 2 months ago

Hi,

I am wondering how do to this with Lumen because there is no database.php?

    <env name="APP_ENV" value="testing"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="QUEUE_DRIVER" value="sync"/>
        <env name="DB_CONNECTION" value="database.sqlite" />
        <env name="DB_DATABASE" value=":memory:" />

Thanks,

Mick

MickBee started a new conversation Should I Be Using Models In Lumen? • 2 months ago

Hi,

Does the fact that with->Eloquent() is commented out suggest that I shouldn't be using models in my API?

Thanks,

Mick

6th August, 2018

MickBee left a reply on Private Method Injection In A Trait • 2 months ago

Yes that is correct. But in my trait I want the Optimus object to be automatically resolved and injected.

Maybe it's not possible and I need to do this:

$optimus = app()->make('Optimus');
Edit Your Profile
Update

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