Update PHP code on a server running the Laravel framework - php

I am the sole person in charge of a website that keeps track of records that other employees submit and compiles them into nice spreadsheets so that non-technical users can easily read them.
The other guy who used to work here quit unexpectedly, and I have to make a small, one-line change to the PHP code that he wrote, the problem is, when I edit the code, it does not seem to change anything. For example, I can completely delete the code that displays an error message, but that error message will still show up. There are other parts of the project that I CAN modify, like XML files and python programs, but the PHP does not seem to care if it is modified.
I vaguely remember a command like 'php artisan serve' but that doesn't seem to help either
After googling the problem, I came across several other commands like 'npm run production' and 'php artisan optimise' but those didn't work either.
Thanks for your help

Are you changing the code directly on the server? Or are you trying it local first? Is the change on a view-file?
Try php artisan cache:clear. It should clear all the caches and probably show your changes.

Related

Laravel Dusk - Run tests & get results via code

I need to make a tool to Browser test my production system. I have read up all about Laravel Dusk and it seems like a perfect tool. However, I need to run tests automatically via schedule and have a dashboard with the results.
I can easily run the command php artisan dusk from the code using the Scheduler, however, how can I get the results? Is there a better option than simply parsing the Console Output from that command? Ideally I would have a way of getting the status of each test (whether it passed or failed) to be able to log, process and display all that information.
The Dusk documentation hasn't got any more information on running the tests programatically, it only has instructions to run via php artisan dusk.
Has anyone encountered this?
Thank you!
The way I have achieved what I needed is to use the command options for dusk/phpunit.
I used --filter=MyTestClass to single out which test I wanted to run, and --log-junit log.log to log the results for that test, which I then parsed via code as well to fetch the results. This allowed me to build a fully custom dashboard that was able to run each test individually, report the results, send notifications etc.
Not the prettiest solution, but it worked well for what I needed. If anyone encounters better way to achieve that (or just use Dusk in general as a browser/scraper outside phpunit) please do post a comment/answer!

Debug PHP Using WAMP and an IDE

I recently started web development. The course I took was to install WAMP and start developing right away. I used an atom text editor, this -combined with wamp- proved to be a very fast way to write client-side code(HTML, CSS, Javascript).
But when I started to write serverside PHP things got a little messy. I should probably explain my site's structure here.
I keep separate PHP, CSS, javascript files for every page on the client side, for the server side a have 2 different types of PHP files:
Files that only perform a specific operation on the database(For example returning "5 more answers"). These are always called by AJAX requests.
Files that load the page for the first time. These are only used when the user opens the page for the first time, they do necessary database queries and return the page. Later requests always go to the 1st type of PHP files.
Now regarding my problem. I debugged until now by printing variables to the screen with var_dump() or echoing. But this started to become too slow as the data I work with grew. I wonder if there is a way of debugging which will let me but a breakpoint in one of my PHP files. Then, when I open it on the browser, on the localhost I created using WAMP, will let me go through the PHP file step by step.
I have been dealing with this issue for 3 days, I tried to make it work with Eclipse IDE but couldn't find a way. Also, there seems to be no tutorials or Q&A on the internet regarding the issue.
Breakpoint debugging opens a whole new world, and is the natural step after var_dump() debugging. Not only does it speed up development, but it provides much more information about your code, as you can step through each line and see what values have been set at each step, and how they evolve as your program executes its code. This means you can track the entirety of the values at different stages with one run - imagine tracking all variables at each point using var_dump()!
Although choosing an IDE is a personal decision based on personal taste, i strongly recommend you try out PhpStorm. If you can get a student licence go for it.
PhpStorm has extensive documentation & tutorials on all features in the IDE, debugging is no exception:
https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html
https://www.youtube.com/watch?v=GokeXqI93x8
I don't know of a specific solution to your issue. I'm not exactly sure what you're doing but as a quick tip, I find add the following snippet to the top of the file useful as it will highly error more easily rather than browser just say nope.
error_reporting(E_ALL);
ini_set('display_errors', 'On');
Hope this help you a bit.
I tried out what's recommended in comments and answers. I first tried Netbeans. To be fair it disappointed me. Download kept getting stuck at 100%, even for different versions. When I stopped downloading and went ahead to create a php project, there was missing parts I guess. I couldn't even manage to create a php project. But that might just be me not being able to do it.
Then I followed #leuquim's answer and #Alex Howansky's comment and downloaded PHPStorm. And I got it to work in no more than 20 minutes. I downloaded it with a student's licence. For people who want to use PHPStorm with WAMP here's a Youtube tutorial:
https://www.youtube.com/watch?v=CxX4vnZFbZU
One thing to note in the video is that, maker of the video chooses PHP Web Application in the Run Configurations. That has been changed to PHP Web Page.

where to find Phprunner query logs?

i have a project generated by Phprunner. some pages respond very slow. then i thought i must inspect generated and executed queries somehow. i'v tried searching trough code and i found lot's of execute functions. i don't know which one is the right execute point.
i'm using Phprunner 9.0 ,Php 5.6 and MySQL.
where can i find the log file or the right spot for putting logger?

Laravel: artisan explination

I'm new to laravel and I'm trying to understand some of the stuff that the artisan command line tool is doing but I can't seem to find a clear explanation.
When I type in:
php artisan help view:publish
It gives me the syntax and different flags I can throw, but no explanation of what the command actually does.
When I look on laravel's website to read the documentation on the artisan tool I get an incredibly brief explanation of how to use the tool but nothing on any of it's commands and the development section of the docs show's how to build command but not what they do.
I've searched around online and I've not found anything that helps. I'm sure I'm wearing my frustration glasses and I'm missing some obvious sources, but it's hard to take those glasses off sometimes.
Does anyone know where I can find manual so I can rtf out of it??
Try the aritsan command: $ php artisan list
It will give you a synopsis of all of the built-in (and custom-made) commands. In the case of view:publish, this is what it reports:
view
view:publish Publish a package's views to the application

Retrieving images in the uploaded pdf document in php

I am trying to display the images in the pdf document that I uploaded to the server as hyperlinks in php so that if user clicks on them they will get the corresponding document.
Please help me ,Thanks in advance!
Use pdfimages, which comes with the open-source xpdf software package (for *nix operating systems). You'll have to call it through exec or the like, then work with the output from PHP. I am not aware of any PHP library that provides this functionality, so you're going to have to experiment.
EDIT
You mentioned that you aren't experienced with PHP... I thought I'd add that this isn't a quick-and-easy type of task, you certainly aren't going to find a bunch of tutorials around the internet for this.
To get started, you'll have to install the xpdf package on your server. There's a lot of different ways to do this depending on which OS you've got.
After that is set up, you'll be using a command line to execute a program on your server; you'll want to capture the output of that command in PHP and work with it further. So initially, you'll want to work out exactly what your command line will look like as well as what the output looks like and means - do this from command line, don't worry about the PHP part yet. In this case, your output is going to be a list of the image files extracted from a given PDF, you're command line call will look something like "pdfimages mypdf.pdf". Play around, find out what happens.
After you work out exactly what command line you need to send and what the command does, you can focus on the PHP angle. In a nutt shell, you want PHP to execute the exact command that you've already worked out. Look at the manual for exec for information on how to call a command line and get the output back. Write your script to make the correct call and show the call's output.
Next, move on to doing something with that output. I presume you'll want to somehow store the extracted images in a web-accessible place, put them in the database, show them to the user, etc. That is the very last stage after you've worked out the initial steps.
Good luck!

Categories