PHP Reddit


Channel's geo and language: not specified, not specified
Category: not specified


Channel to sync with /r/PHP /r/Laravel /r/Symfony. Powered by awesome @r_channels and @reddit2telegram

Related channels

Channel's geo and language
not specified, not specified
Statistics
Posts filter


Laravel Passport or Sanctum

🔗 [https://www.youtube.com/watch?v=LE1TC4WS4CY](https://www.youtube.com/watch?v=LE1TC4WS4CY)

After the Laravel Sanctum package was released? Everywhere question was asked that When to use Sanctum and when to use Passport? So, in this video, you will see what is the difference between Laravel Sanctum & Passport package, and which could fit your need.

https://redd.it/hebq06
@r_php


Weekly /r/Laravel Collaboration Thread - June 23, 2020

Working on an open source project? Fixing a bug in Laravel? Looking for contributors?
Share it in this weekly collaboration thread!

https://redd.it/heao46
@r_php




New Dev machine. What will you install?

Imagine you have just bought a new pc/Mac. What are you going to install to start developing/deploying your laravel app?

Specify the os.

https://redd.it/he9bfu
@r_php




Stuck at auth()->attempt()

I am starting a new project. its a user portal with social login.
since its frontend is on ReactJS so I am building every thing with API. for that I am using laravel 7 with passport. I am following a tutorial video from youtube. and I am able to register the user. (getting user object with access token).


But when I go to login, it always fals at `auth()->attempt($credentials)` . First I made a mistake (youtuber made a mistake) I did not encrypt my password while signup so my password was plaintext in DB. but then I corrected it. still I was not able to login.


Then I searched more and realised that Auth::attempt() require hashed password. so I did `$password = bcrypt($req->password)` but still its not working. can anyone tell me what I am doing wrong?


here is my authcontroller: [https://pastebin.com/geEHDELT](https://pastebin.com/geEHDELT)

https://redd.it/hdtqdk
@r_php






Best approach to convert php app to laravel?

Hi all,
Right now I'm working on a web application developed on a custom php framework.
The framework was build to run under php 5.6 but can handle 7.3 with any error.

I would like to migrate to laravel due to new technologies and to have a much more robust application to work with (also performances, level separation, etc).

What I'm asking is: is there a good approach to migrate to laravel? There is something that I have to keep in mind, or have I to "move" my logic to the new structure?

Consider the fact that I don't want to change my database structure (mainly because it's full of data). I can consider making some minor changes.


TLDR: I have a custom php app and I want to move go laravel.

https://redd.it/he2l96
@r_php


What exceptions custom exceptions should I throw in general for an API?

I've built a custom exception handler for a Saas API that will be consumed by my Vue SPA:

**Handler.php**

public function render($request, Throwable $exception)
{

$response = $this->handleException($request, $exception);
return $response;
}

public function handleException($request, Throwable $exception)
{

if ($exception instanceof \Stripe\Exception\ApiErrorException) {
return response()->json([
'message' => $exception->getMessage(),
], 500);
}

if ($exception instanceof MethodNotAllowedHttpException) {
return response()->json([
'message' => 'The specified method for the request is invalid']
, 405);
}

if ($exception instanceof NotFoundHttpException) {
return response()->json([
'message' => 'The specified URL cannot be found']
, 404);
}

if ($exception instanceof HttpException) {
return response()->json([
'message' => $exception->getMessage()]
, $exception->getStatusCode());
}

if ($exception instanceof ModelNotFoundException) {
return response()->json([
'message' => 'Entry for '.str_replace('App\\', '', $exception->getModel()).' not found']
, 404);
}

if (config('app.debug')) {
return parent::render($request, $exception);
}

return response()->json([
'message' => 'Unexpected Exception. Try later']
, 500);

}


What I'm wondering is what other generalized exceptions should I worry about throwing? Is there any that I am missing? Where would I import these other exception handlers from?

I haven't seen much on this. I've only really seen tutorials on how to handle exceptions and not ones you should customize for an API by default.

Thanks for the help. I'm new to API development.

https://redd.it/he17hk
@r_php


I'm developing a service that allows you to run artisan commands straight from Slack
https://giles.app

https://redd.it/he0btc
@r_php


What's your current salary?

- How much do you make?
- Where?
- Remote or no?
- Environment: relaxed/stressful, learning environment
- What technology do you work with?
- Years of experience?

https://redd.it/hdzqcr
@r_php






gRPC and PHP – how to make them work together

When I talk to people about microservices, PHP isn't usually the first thing that comes to their minds. But we've done it, at the company in which I work, and we've been pretty successful. One of the things which helped us a lot was, of course, implementing the powerful gRPC. It's usually associated with Node.js but, as some of you probably know, gRPC actually works with PHP pretty well, too. My colleague, Agnieszka, recently wrote a [piece](https://tsh.io/blog/grpc-php/) about that – I thought that it can be a nice tutorial for some of you here in r/PHP. Let me know what you think.

https://redd.it/hdqvn7
@r_php








Factories in PHP - what's the deal?

How do you deal with factory classes in PHP? Do you have a factory maker? Do you use anonymous classes that implements a FactoryInterface? Or do you just use anonymous function that return a new instance? Not sure which way is best, and how different frameworks deal with it. Use-case is the usual, mockability of dependencies.

https://redd.it/hdqx50
@r_php


Weekly /r/Laravel No Stupid Questions Thread - June 22, 2020

You've got a tiny question about Laravel which you're too embarrassed to make a whole post about, or maybe you've just started a new job and something simple is tripping you up. Share it here in the weekly judgement-free no stupid questions thread.

https://redd.it/hdo8l0
@r_php

20 last posts shown.

5

subscribers
Channel statistics