PHP - Moved: How To Integrate Phpunit With Php Pro Custom Php Framework?
This topic has been moved to Application Frameworks.
http://www.phpfreaks.com/forums/index.php?topic=317468.0 Similar TutorialsThis topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=319964.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=347122.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=347050.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=348359.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=328743.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=324009.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=327717.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=332538.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=322256.0 Hi y'all. First off, posting this here to hopefully avoid the noise that's happening in the Applications sub-forums, so mods please feel free to move if it's too inappropriate here. Anyway, I'm currently doing a skills assessment for a potential new job in Laravel - if I wasn't using Laravel I would've been done hours ago, but one of the requirements is Laravel. Honestly, for the most part I dig it - it's pretty simple, despite it's reliance on magic. Anyway, I've written a couple API routes and when I visit them in the browser everything works exactly as expected and desired. However, when I run the pre-built test file, I get a Symfony\Component\HttpKernel\Exception\NotFoundHttpException for /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php. The route as defined in api.php: use App\Http\Controllers\User; /** * I tried using a Resource Collection here - there's obviously something about those * that I'm missing, because it actively refused to do anything worthwhile. I'd pass in * UserModel::with('timelogs')->get() like I use in \App\Http\Controllers\User::getTotalSeconds(), * and it didn't care. Just printed out absolute garbage, no matter what I fed to it. */ Route::get('/user-timelogs', function(Request $request) { $u = new User; return $u->getTotalSeconds(); }); And the controller code: namespace App\Http\Controllers; use Illuminate\Http\Request; use App\User as UserModel; class User extends Controller public function getTotalSeconds() { $users = UserModel::with('timelogs')->get(); $ret = []; foreach($users as $user){ array_push($ret, [ 'user_id' => $user->id, 'seconds_logged' => $this->calculateTime($user->timelogs) ]); }; return json_encode($ret); } private function calculateTime($logs) { $totalTime = 0; foreach($logs as $log){ $totalTime += $log->seconds_logged; } return $totalTime; } } The model file for good measu namespace App; use Illuminate\Notifications\Notifiable; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use Notifiable; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password', 'id', ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', ]; public function timelogs() { return $this->hasMany('App\Timelog'); } } Again, when I visit localhost/api/user-timelogs, the user IDs and correct total of seconds is right there. It's just in the test file that it's an issue. Anybody have any ideas? Edited September 21, 2019 by maxxdwas totally not done typing... This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=348687.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=323633.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=358297.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=352987.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=315930.0 I'm sure it's not much, but I'm not understanding something with custom error handlers: I've created a custom error handler, which I initially set when my page loads : set_error_handler(array ( new ErrorHandler(), 'handleError' ));
It seems to catch all internal PHP errors, such as if I: var_dump($non_existing_var); right after the set_error_handler.... Now, I have an object that throws an exception after: set_error_handler(array ( new ErrorHandler(), 'handleError' )); $locale = new \CorbeauPerdu\i18n\Locale(...); // this should throw an exception ... I thought that with an error handler set, I could 'skip' the try/catch for it, but doing so, PHP spits out in its internal log: PHP Fatal error: Uncaught CorbeauPerdu\i18n\LocaleException: ....
My error handler doesn't catch it at all before, thus my page breaks!! If I want it to go through the error handler, I have to init my Locale with a try/catch and use trigger_error() like so: set_error_handler(array ( new ErrorHandler(), 'handleError' )); try { $locale = new \CorbeauPerdu\i18n\Locale(...); // this should throw an exception } catch(Exception $e) { trigger_error($e->getMessage(), E_USER_ERROR); } ... Is this normal ? I thought one of the goals of the error_handler was to catch anything that wasn't dealt with? Thanks for your answers! This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=323879.0 Hi there, This forum has been helpful to me so far. I'd like to thank you for your help. Now the question is, we will be using xe.com services for our shopping cart and prices. Based to the customer's location the currency must change. For example, if the customer is sitting in Europe, the currency for the product and the shopping cart will be displayed in Euros, similarly for the US customers it will be in USD. I would like to know how we can do this using xe.com and what steps are required. Any comments/feedbacks are always welcome! Thank you! Hi, Can any help me out how to integrate skype with php? or poeple leave a message on my skype through php? |