I have a Laravel backend which basically works as an API and dashboard for my database and its data. The data updated daily using a Python script directly to the database. Is there any way to trigger a Laravel Scout update (so that the row is updated in Algolia as well) outside the PHP project?
The only alternative I thought was to use a Laravel api to handle the changes between the python script and the database so that only Laravel can communicate directly to the database.
However, I would really prefer if there was a way to add a listener or whatever to that without using Laravel in between since the python script is REALLY fast.
There are two ways for that:
1). You can use Laravel API to update Algolia entries into database.
2). Maybe you can use Algolia Python Library.
I suggest you to use Laravel API. You can simply call API URL from Python Script. You need to write clear PHP code of Laravel controller API, because python is fast and it will need to communicate fast with api.
Also: You can simply use Python module named flask to connect to your laravel database and make changes what you want in database. (Every database can be managed from different programming languages such as PHP, Ruby on Rails, Python and etc.)
Only laravel can't communicate to your database, it can be done from Python too (But of course it's mainly possible from laravel too).
If you want to reindex everything, which seems to be the best way for you, I would just execute php path/to/artisan scout:import "App\Model" via Python.
If you want to update each model, because you will only edit a very limited number, like Giorgi said, I would use the Algolia Python client and call Algolia's API directly. It should be very easy to write.
https://github.com/algolia/algoliasearch-client-python
Related
I'm working on an application in which I want to use both Laravel and Google BigQuery to store the data.
I want to continue to use Laravel's Eloquent models for easily generating SQL, but I want all the SQL to be sent to Google BigQuery for storing and reading the data.
Is this possible with Laravel?
What is the best way to accomplish this?
Failing to find a library that is already handling this ( You would want something similar to Laravel Scout ) - You could Write a wrapper around the Google BigQuery Service ( with something like this https://github.com/schulzefelix/laravel-bigquery there is other packages available as well ) - With this you would then need to look at writing events off of the Laravel model you want to send to BigQuery https://laravel.com/docs/5.5/eloquent#events if you want to listen for many different events on a given model i would look into using Observers - https://laravel.com/docs/5.5/eloquent#observers
I would start with the above & have a look at https://github.com/laravel/scout for ideas on how you might be able to implement this.
I'm sure the OSS community would be very thankful if you where to package it up as well.
Good luck!
Hello guys I need help here,
I want to send PDF mails to users on a monthly basics. but the PDF will have values from the db. so each users has a different content from another user all taking values from db. If i can't achieve this perfectly on Laravel I need another language that can help me achieve this thanks.
$schedule->command('custom:command')
->monthly();
You can achieve anything in Laravel which you can achieve in PHP :) and as far as web development is concerned, you can achieve anything in PHP :)
However, I am not sure what exactly is your question about so I will answer all aspects of sending an email with dynamic pdf.
Get fillable PDF
First of all, you need fillable fields in your pdf in order to generate a dynamic pdf in run time. If you dont have fillable fields in your pdf, you can create them using any online tool. One example is: https://www.pdfescape.com/
You can also use Adobe to do so if you like.
Create a PDF with dynamic data
Once you have your empty, fillable PDF, then you can populate the data in it using PDFTK library. Of course, you will have to install this tool in your Server in order to use it.
I recommend using it directly, running exec or similar commands in PHP. However, if you are not comfortable, you can use various Pdftk wrapper, available in Laravel. One example is: https://github.com/mikehaertl/php-pdftk
I myself prefer using exec directly from PHP. Here is a REALLY GOOD tutorial for that: https://www.sitepoint.com/filling-pdf-forms-pdftk-php/
Send the email
Well once you have your PDF generated and saved on Server, all you need to do is attach it with your email and send. You can find all about attachments in Laravel here: https://laravel.com/docs/5.1/mail#attachments
Run it via cron
If you have to do it on a regular basis. I advise you create a cron on your Server. There are various ways to do that. I advise you do it via cPanel, if you have one on your server of course as it provides very user-friendly way of creating crons. If not, you can also use terminal to edit the cron files in Linux Server.
I do not recommend using Laravel inbuild scheduler because it has known issues.
Well that's it, voila..that's the whole process of sending dynamically generated PDFs via email on regular basis.
Good luck!
I want to use backpack to manupulate REST api data in my project.
I always used a backpack to administrate data using eloquent models without REST.
But now I want to request the data from api in controllers and show it in backpack crud tables.
I can request the data with guzzle, add multiple columns dynamically with $this->crud->addColumns();.
Could you tell me what method I should use inside my EntityCrudController setup() method to add the data like this? Thanks.
Using Laravel 5.8 with Backpack 3.5.
For REST using Slim framework 3.
I’m afraid it is not recommended to use Backpack with your custom REST API. Backpack depends on Eloquent to do everything related to database interaction, so you’d have to overwrite a lot of things.
While technically it is possible (you could create the operation methods in your EntityCrudController like store(), update(), destroy(), search() and call your API instead of Eloquent - it would be a lot of work. And it will probably be easier to just create CRUDs without Backpack.
I need to develop an application get html content from certain urls and shows them in my own web app.
UI web application will be laravel 5.3 its ok. But the thing is key pointhere that retrieves data from urls(read and parse html content of via url)
and writes it to postgresql db migth be developed within laravel also ?
Before I decide to create this post I feel had to make an web service in python and read url and writes to db and read them within laravel web application. Which one is better or more efficient?
Besides them I also wonder that is possible develop such a web service in laravel
You can use ixudra/curl package. It's powerful, easy to use and you will be free to do anything you want. You can also save results into database. Make sure php-curl module installed on your php before you use this package. there is a pacakge named Guzzle and you can use that package but it's a little bit complicated than ixudra.
when you get html content from requested urls. You can parse the content with yangqi/htmldom package.
I understand that this is a very broad question and could get flagged but I need inputs from experienced programmers and will ask it anyway. If there is another forum where I can post this question, please let me know.
Currently we manage all our application information in an Excel spreadsheet. At a high level it contains an app id, the server names that it is hosted on and the name of the environment. The Excel spreadsheet has become too large and I am looking to build a simple application for it.
Ideally, I would like to write this app on Windows as everyone uses Windows but dont know how to go about it in Windows. I then thought of using MySQL and PHP or Perl (CGI) to build this but thought of exploring something new. I read about Joomla and a few other CMS products which make it very easy to build websites but am not sure whether these allows me to pull information from a database.
I am seeking inputs on what would be a good way to way to build this application.
Use Joomla! CMS is a good choice and to pull data from database you may use webservice calls. So, you will able to create a CMS website using joomla and will able to pull data easily from database with the help of webservice.
You can get webservice support in joomla by installing component redCORE in joomla.
Component: https://github.com/redCOMPONENT-COM/redCORE
Wiki: http://redcomponent-com.github.io/redCORE/?chapters/webservices/overview.md
Other videos: https://www.youtube.com/watch?v=UzJkC7f9fJE
https://www.youtube.com/watch?v=1NRT5jh3Ewc
Joomla dev group discussion https://groups.google.com/d/msg/joomla-dev-cms/3OctbkIZlQw/5d_1MLrzbgYJ
You can also post questions in Joomla forum http://forum.joomla.org/
I think Joomla is a great option to handle big loads of information. If you already know PHP and don't need to reinvent the wheel, it's cool. The way of handling data in Joomla is using Components.
If you want to try, it would be as easy as installing a local copy of Joomla, building the field structure on component-creator.com installing it and importing the data inside the component using phpmyadmin.