Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup changes #3

Merged
merged 13 commits into from
Oct 28, 2022
Merged

Setup changes #3

merged 13 commits into from
Oct 28, 2022

Conversation

ashleycoles
Copy link
Contributor

No description provided.

$this->model = $model;
}

public function __invoke(RequestInterface $request, ResponseInterface $response): ResponseInterface
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one thing to think about.

The ResponseInterface does not include the withJson method, which means phpstorm gives some weird warnings when you use it.

We could fix this by changing the type-hint to Slim\Http\Response, but then it looks a bit weird having the response be an interface, but the request being an actual class.

Does anyone have any thoughts?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it also breaks D in SOLID

it could be a really good teaching point, but it could also confuse them unnecessarily

we could use the class as the type hint for both, still breaks SOLID but is consistent atleast

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a better idea
slimphp/Slim-Http#194

Comment on lines 16 to 19
public function __construct(PDO $db)
{
$this->db = $db;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing to think about here - I've added this example model which takes a PDO connection, but the issue there is that students will need to connect slim to a DB straight away.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having a modal with PDO doesnt feel like a skeleton anymore, I see the benefit for students and teaching, but as a usable skeleton app your gonna have to remove the modal and probably the controller every time.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh just realised the modal doesnt actually use the DB, so they only need to have a DB with he right name, which isn't too bad

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we could be sneaky and when we get them to do the SQL excercises in week 2 (adults/children etc..) we could make that named example. That way we could pre-emptively solve the prob before it arises?

Copy link

@mporam mporam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel like this needs some discusison, as it doesnt feel like a skeleton anymore, I see the benefit for students and teaching, but as a usable skeleton app your gonna have to remove the modal and probably the controller every time

return $renderer;
};
$container[LoggerInterface::class] = DI\factory(LoggerFactory::class);
$container['renderer'] = DI\factory(RendererFactory::class);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think we should normalise the use of ClassName::class for the DIC keys, make it consistent with the Logger

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah agreed, def a syntax for the students thats good to get comfortable with


class CoursesAPIController
{
protected CoursesModel $model;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why protected and not private?

$this->model = $model;
}

public function __invoke(RequestInterface $request, ResponseInterface $response): ResponseInterface
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it also breaks D in SOLID

it could be a really good teaching point, but it could also confuse them unnecessarily

we could use the class as the type hint for both, still breaks SOLID but is consistent atleast

Comment on lines 16 to 19
public function __construct(PDO $db)
{
$this->db = $db;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having a modal with PDO doesnt feel like a skeleton anymore, I see the benefit for students and teaching, but as a usable skeleton app your gonna have to remove the modal and probably the controller every time.

Comment on lines 16 to 19
public function __construct(PDO $db)
{
$this->db = $db;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh just realised the modal doesnt actually use the DB, so they only need to have a DB with he right name, which isn't too bad

return $renderer;
};
$container[LoggerInterface::class] = DI\factory(LoggerFactory::class);
$container['renderer'] = DI\factory(RendererFactory::class);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah agreed, def a syntax for the students thats good to get comfortable with

src/Factories/PDOFactory.php Outdated Show resolved Hide resolved
Comment on lines 16 to 19
public function __construct(PDO $db)
{
$this->db = $db;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we could be sneaky and when we get them to do the SQL excercises in week 2 (adults/children etc..) we could make that named example. That way we could pre-emptively solve the prob before it arises?

app/routes.php Outdated Show resolved Hide resolved
app/settings.php Outdated Show resolved Hide resolved
app/dependencies.php Show resolved Hide resolved
src/Factories/PDOFactory.php Outdated Show resolved Hide resolved
@mporam mporam merged commit 68563f7 into main Oct 28, 2022
@mporam mporam deleted the setup-changes branch October 28, 2022 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants