-
Notifications
You must be signed in to change notification settings - Fork 33
Add landing_getting_started_1 code samples #180
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
landing_getting_started_1: |- | ||
```yml | ||
# Configure your entities by adding them in config/packages/meili_search.yaml | ||
meili_search: | ||
url: 'http://127.0.0.1:7700' | ||
api_key: 'masterKey' | ||
indices: | ||
- name: movies | ||
class: App\Entity\Movie | ||
``` | ||
|
||
```php | ||
<?php | ||
// src/Controller/MoviesController.php | ||
namespace App\Controller; | ||
|
||
use App\Entity\Movie; | ||
use Doctrine\Persistence\ManagerRegistry; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class MoviesController extends AbstractController | ||
{ | ||
#[Route('/add-movies', name: 'addMovies')] | ||
public function addMovies(ManagerRegistry $doctrine): Response | ||
{ | ||
$entityManager = $doctrine->getManager(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure to understand, for me you already said it will be automatically updated some line below right?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, but do you think the comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see any problem to have it on a sample code to remind this information. Will the content of this comment be mentioned before or after the sample code? If not, it seems useful to me because there is a bit of magic with the ORM hooks here, it also helps someone who doesn't necessarily read the surrounding text and copy and paste the sample code directly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's ok from my POV to let it. We added it to Rails as well, and I agree with guillaume: it's a little bit magic and not obvious, from my POV |
||
|
||
$movies = ['Carol', 'Wonder Woman', 'Life of Pi', 'Mad Max: Fury Road', 'Moana', 'Philadelphia']; | ||
|
||
foreach ($movies as $title) { | ||
$movie = new Movie(); | ||
$movie->setTitle($title); | ||
|
||
$entityManager->persist($movie); | ||
} | ||
|
||
// Inserting data in your DB table will automatically update your Meilisearch index | ||
$entityManager->flush(); | ||
|
||
//... | ||
} | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this file has two different languages, I must use markdown here, or the landing page will understand it?
CC: @bidoubiwa @mdubus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! It will not unfortunately :/ We have the same issue in angular. We settled for this with morgane: https://github.com/meilisearch/meilisearch-angular/blob/main/.code-samples.meilisearch.yaml
We are not sure how ugly it will look, when we now more we can potentially try things out.