What’s the best way ( or maybe the way it’s actually done ) of creating an artisan command for generating custom classes or files? Like php artisan make:console itself that creates a php class for our …
Tag: php
How to use strpos($_SERVER[‘REQUEST_URI’] to generate active classes from url segments
We’ve found a lot of answers for this but don’t fully understand them (or the strpos manual page) so sorry if this is already answered. Setup: Consider the following urls… http://www.domain.com/…
How can I easily switch between PHP versions on Mac OSX?
I would like to test my application on PHP 5.3 up to PHP 7.0. Where and how can I install the versions and how can I switch them by running a small script? Answer If you have both versions of PHP installed, you can switch between versions using the link and unlink brew commands. For example, to switch between…
Fatal error: Class CI_Session_files_driver contains 1 abstract method
Fatal error: Class CI_Session_files_driver contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (SessionHandlerInterface::open) in C:xampp…
How to use a Function of Switch/Case, if at all?
I have various products inside a database, each has its own price, the pattern to output a product price is: $product[i][“price”] I also have various “product types”, which are manually defined in my code, each with index number that will relate to each product accordingly: I want to e…
How can I sanitize laravel Request inputs?
I have MyRequest.php class extending AppHttpRequestsRequest. I want to trim() every input before validation because an e-mail with a space after it does not pass validation. However sanitize() was …
Laravel 5 console (artisan) command unit tests
I am migrating my Laravel 4.2 app to 5.1 (starting with 5.0) and am a lot of trouble with my console command unit tests. I have artisan commands for which I need to test the produced console output, …
Merge an array value with another array
I Have 2 arrays: I am looking to merge both of them to get the below result using foreach: So the result will be displayed like: Answer You need to keep a running integer count of the key offset to be able to get the same index from $values; we’re doing this here by looping over the keys and using
How to fetch entities in db while using doctrine fixtures?
I have been the ContainerAwareInterface on my LoadAdvert class so I can call and use the EntityManager to retrieve users in the database. However, when executing php bin/console doctrine:fixtures:load, the entity manager retrieves only an empty array, as if there was no user in the db. Answer Here it is how I…
PDOException: SQLSTATE[HY000]: General error: 3 Error writing file ‘/tmp/MYHKgYpv’ (Errcode: 28)
I have installed Visitor Module Drupal 7. I have viewed the reports using www.domain.com/visitors. All the reports are working well. But when i view the user activity report it shows below error. PDOException: SQLSTATE[HY000]: General error: 3 Error writing file ‘/tmp/MYHKgYpv’ (Errcode: 28): SELE…