I’m trying to mock a method in the Model so that I am able to test the controller api endpoint with different scenarios. I am currently using Laravel 8 with PhpUnit and Mockery package. In the route I am using Route model binding. api.php ProjectController.php ProjectControllerTest.php I am currently ge…
Tag: php
Logging into a soap API with cURL and Laravel
I’m having some trouble with this. I am trying to login to a Soap API with SSL I have generated the .pem file and can verify it is good by doing the following The following give me HTTP/1.1 202 Accepted Now, when I essentially try to do the same thing within a laravel controller with the following, I ge…
Magento 2 Block template is working locally and doen’t on server
I’m new at Magento I created a new page to list some data that is coming from an API, and I used that a Block base on phtml template and I pass the data loaded from API to the block to list it. this code is working fine locally but when I deploy it to the server it crashes please
Add quantities from an input created with While in PHP to a DIV
i have a little problem when try do this operation: This its the crazy code to try do. INPUT TO DO : DIV TO SHOW ALL CRAZY CODE Thanks for the time and help. Answer Work to separate PHP from the clientside code, you can initialize the values from PHP onto the DOM by setting the values of the inputs
Symfony cascade persist or merge duplication
I have a problem with the cascade persist or merge, I have an application with two entities task and table (task_implements) When I create a task I choose cultures that are linked: If the user chooses 3 cultures => 3 tasks are created If the user chooses 3 cultures then 2 vehicles => 3 tasks must be cre…
How to load data from cache to a form in a laravel application?
I’m developing a site in laravel. I have a view for editing and creating posts that brings the data stored from the database. For example: The problem is that when the user makes modifications, try to save the data and has validation errors, he loses all the modifications he made (because when laravel r…
regex skip match if its follows by whitespace and a keyword
Currently trying to match comments with regexes but only if no function follows. Currently I use a regex which also matches the keyword function. And then check in the source code (php) if this group is set or not. https://regex101.com/r/l0j1ip/1 Now the question is whether it is possible to realize with pure…
Warning: session_start(): Cannot find save handler ‘redis’
I want to set php.ini to use Redis as session handler. I did it this way: My Php application and Redis are running in 2 different containers. This is the code I’m trying to run in Php: Due to my searchs I found that I should install: but E: Unable to locate package php5-redis I’ve also tried: php-…
Getting a product price from an ecommerce site using file get content
I am trying to get a product price using php and file_get_contents function. Here is my code. It is loading the whole page however I just need the price from this page. Can someone please help? Thanks Answer PHP Simple HTML DOM parser is a godsend for this kind of thing Get the code here Just include it on yo…
How to list files inside public folder?
I have a persistent volume defined in server under www/public/images/logo/ I want to list all the files inside that folder. So far I have done following lines with no luck. Can anybody please help ? Answer If you are want to list all files on same server then you can use php function scandir(); If you are wan…