An automation to download a file to my laravel project - php

I have some files I want to add to my laravel project on a regular basis say every hour
till now I had to download the file manually then move it to my laravel project
any particular thing I should look for to have this done?

You can write the command to create a file, and download or email the file to the system or user. After that, you can run a cron job of this particular command. This will solve your issue

Related

Can I update a single file of Laravel project when it's hosted and live?

I have a Laravel application. It's hosted and people are using it. Actually it's live now. But there's a little issue on images. Some images are not displayed correctly. So I need to fix that. Only some HTML parts and it's done by Blade templating engine. I have access to server and I can edit that files online and fix that issue.
Is that can be a problem ? Do we need to compile or something like that ?
Yes you can edit that file. But make sure you have take a proper backup of the code on your local system and after updating the file on server update your local copy of that code as well.
And after update run the following command through terminal:
php artisan config:cache
This command remove the existing cache and the changes are reflected immediately.

Monitor directory for file creation

I'm using a VPS with CentOS 6.5, I need to create a PHP script that looks if a file was uploaded to my home/user/public_html/uploads and take it's name and save it in a DB (I can do this part). I do not know when files will be uploadd to that directory, it could be at any time so I'm wondering if there is a PHP or any other way (Linux) to monitor the upload folder for any file created inside it and run the PHP script, I found some articles on Google about things like inotify, auditd but there is no clear tutorials on how to do that. Can you help me please?
Thanks

CakePHP Update button

I'm building a CakePHP-application that people can install on their hosting.
In the meantime I'm still working on the application, so I want people to be able to update it just by clicking on an update button.
From the moment I write new code in a Controller, make new Components,..., I push it up to the "Source-server" and they click on update then they have to have all this updated code on their server as well.
I was thinking to write an exec (command line) that executes a git pull/fetch but not every hosting has git installed, so that's not the best solution.
Can somebody help me out with that?
Thanks in advance,
AƤron
You need to implement a package system: Your php script will download a zip file that contains all the code from a source, unpack it in a temporary folder, read the meta data file that tells your script what version the plugin or application code is, compare it with the running version, maybe do some security checks like a checksum or if you like to implement that a signature check. When the checks were successful you'll have to replace the existing files with the files from the package.
You could even give the option to do a rollback if you keep the zip of the previous version. Don't forget that your update code needs a way to fire database migrations as well. I would develop a "Package" or "PluginManager" plugin that does all of that. The event system can be used to trigger events when things are installed / deinstalled.
Wordpress does it this way, you might want to look at what it does but I would not recommend to take any of the fugly wordpress code, just use the concept.
Like joomla , wordpress you can create installation package which can check the current version and check server version.
stept2
after compression it create database and file backup
step3 download pakedge from server under a temp directory
step4 replace new lib with older one
step5 if update successfully then delete pkg from temp directory and delete old file backup
step6 if fail replace the site sitebackup

ATK4 & cron job, using of ds-addons/Scheduler

I need cron job for my new application and found a nice add-on by DarkSide, but im having some difficulties using it.
The add-on is here: https://github.com/romaninsh/TemaOrig/tree/master/ds-addons/Scheduler
I have installed it till step 3, where windows scheduler reports "The windows cannot find the file specified".. but i guess i will try this tommorow.
What im really interested is some example of configuration (step4)
4a) Set scheduler global settings in "Config" tab.: How should i insert them, directly into database? So how do i insert: Important is, that you set "Heartbeat time" to exactly the same value (in minutes) what scheduled in your cron tab or Windows task scheduler.
Just a guess:
name: Heartbeat time
value: 5? Like every 5 minutes? Or do i put cron expression?
description: ??
4b) Create Tasks.
I really do not know how to use this. What do i insert for Code, Class, Action?
Actually original source of ds-addons is here: https://github.com/DarkSide666/ds-addons and I'm author of this addons pack and particular add-on - Scheduler :)
Questions and tips for you:
What is folder structure in your project folder? I'm of course especially interested where ds-addons folder is located.
Which version of Windows are you using and do you have Administrator rights on that machine?
Can you find file wscript.exe in your system hard-drive / Windows installation folder? In my WinXP it's located in c:\windows\system32 folder and as result is in PATH environmental variable and is accessible from anywhere. If that's not your case, then you have to provide full path to wscript.exe
4a is no more needed in latest version of add-on
There is a sample Task class in readme in latest version of add-on
In Windows scheduler you can set script to execute every minute or every 3-5 minutes not less. Otherwise you'll have big delays between scheduled time (in add-on) and actual execution time.
Solution:
Download latest add-on version from https://github.com/DarkSide666/ds-addons and check out changes in it's readme file.

Working Directory for a Cron Job

I am testing an application in MAMP and would like to add a cron job, or as I am on a mac the job through is run through launchctl. My cron is a php file that runs a database query. Naturally the php file and mysql db are in separate directories. Where should I change my working directory to such that the cron will query the database? FYI, I have a standard installation /Applications/MAMP/...
Many thanks.
My mistake above was that I was trying to point to the database's directory, when the php file had already handled that for me. Running the program was as simple as running the following code:
php -q /path/to/my/doc.php
I found it was easiest to manage launchtl through a $5-$10 program called lingon. Highly recommended if you are considering managing multiple crons at a time. Otherwise, if you want to stick to the command line, this is a good tutorial.

Categories