CoderFunda
  • Home
  • About us
    • Contact Us
    • Disclaimer
    • Privacy Policy
    • About us
  • Home
  • Php
  • HTML
  • CSS
  • JavaScript
    • JavaScript
    • Jquery
    • JqueryUI
    • Stock
  • SQL
  • Vue.Js
  • Python
  • Wordpress
  • C++
    • C++
    • C
  • Laravel
    • Laravel
      • Overview
      • Namespaces
      • Middleware
      • Routing
      • Configuration
      • Application Structure
      • Installation
    • Overview
  • DBMS
    • DBMS
      • PL/SQL
      • SQLite
      • MongoDB
      • Cassandra
      • MySQL
      • Oracle
      • CouchDB
      • Neo4j
      • DB2
      • Quiz
    • Overview
  • Entertainment
    • TV Series Update
    • Movie Review
    • Movie Review
  • More
    • Vue. Js
    • Php Question
    • Php Interview Question
    • Laravel Interview Question
    • SQL Interview Question
    • IAS Interview Question
    • PCS Interview Question
    • Technology
    • Other

29 April, 2024

How do I run a scheduled AWS Fargate task as a one-off?

 Programing Coderfunda     April 29, 2024     No comments   

For a system I'm building, I have set up an AWS scheduled Fargate task through the python cdk. This task is started every hour and retrieves events from the past hour from some external endpoint to further process. This scheduled task works to satisfaction.


Now, I want to also be able to run this task on demand. This will be for initial loads where (much) more than one hour of event data is to be retrieved, or for corrective loads when the sheduled task has failed for any reason. These will probably not need to happen more than about once each two months.

---



Is there a way I can create a one-off task, preferably with altered environment variables, from my already-defined scheduled Fargate task? This one-off task should then be able to be started ad-hoc from the AWS dashboard.

---



As it stands, I can manually start a new one-off task from the task definition I created for the scheduled Fargate task. But this requires the user (which won't always be me) to specify all sorts of parameters like selecting the vpc, subnets, and environment variable overrides. I'd rather reuse those specified for the scheduled fargate tasks, or have them stored somewhere, so that these don't need be entered manually. Is this possible?


Related questions




I feel my question is similar to this one, but the page linked to in that answer does not really tell me how to accomplish a one-off or "standalone" task through the cdk.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Send message via CANBus

 Programing Coderfunda     April 29, 2024     No comments   

After some years developing for mobile devices, I've started developing for embedded devices, and I'm finding a new problem now.
This embedded device has the same peripherals as a mobile phone, ie, WiFi, BT, USB, etc. but it also has a CANBUS connector, and I need to communicate through it.


The problem I'm facing is that I don't find much information of how to do this.


I would appreciate if anyone who has experienced with it could show me the way of doing it, at least, how can I start with it. The basic functionality that I need to achieve is to send a basic message through CANBUS from the embedded.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

11 April, 2024

Create Reusable Blade Components in Laravel

 Programing Coderfunda     April 11, 2024     No comments   

In Laravel, reusable Blade components provide a convenient way to encapsulate UI elements and logic for reuse across your application. Let's walk through creating and using reusable Blade components in Laravel: 1. **Create a Component:** To create a Blade component, you can use the `make:component` Artisan command: ```bash php artisan make:component Button ``` This command will generate a new Blade component class in the `app/View/Components` directory. 2. **Define Component Logic:** Open the generated component class (`Button.php` in this case) and define the logic for your component. This includes properties, methods, and rendering logic. ```php <?php namespace App\View\Components; use Illuminate\View\Component; class Button extends Component { public $type; public $text; public function __construct($type = 'primary', $text) { $this->type = $type; $this->text = $text; } public function render() { return view('components.button'); } } ``` 3. **Create the Blade View:** Next, create the Blade view file for your component. By default, Laravel expects this file to be located in `resources/views/components`. So create a file named `button.blade.php` in that directory. ```blade <button class="btn btn-{{ $type }}">{{ $text }}</button> ``` 4. **Use the Component:** You can now use your component in any Blade view by using its tag name. For example: ```blade <x-button type="primary" text="Click me" /> ``` This will render a button with the specified type and text. 5. **Passing Data to Components:** You can pass data to your component by adding public properties to the component class. These properties can be set when you include the component in your Blade views. 6. **Reusing Components:** You can reuse your component across your application wherever needed. Simply include the component tag with the desired properties. By following these steps, you can create reusable Blade components in Laravel to keep your UI code organized and DRY (Don't Repeat Yourself).

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Laravel Upgrading from Laravel 10 to Laravel 11

 Programing Coderfunda     April 11, 2024     No comments   

 The detailed upgrade document is available on the official Laravel document.

Also, read the Laravel 11 release notes. It will help us to upgrade our application.

1. PHP Version

Our first step is to upgrade your PHP version. Laravel 11 requires PHP 8.2.0 or greater.

2. Update Composer Dependencies

Now open our composer.json and update the following dependencies

  • php to^8.2
  • laravel/framework to ^11.0
  • Remove the guzzlehttp/guzzle package. Because it is already included in laravel/framework
  • nunomaduro/collision to ^8.1

I have updated some require-dev packages to match the Laravel 11 composer.json

diff --git a/composer.json b/composer.json
index 546a826..22a7942 100644
--- a/composer.json
+++ b/composer.json
@@ -5,25 +5,24 @@
"keywords": ["framework", "laravel", "boilerplate", "admin panel"],
"license": "MIT",
"require": {
- "php": "^8.1",
+ "php": "^8.2",
"balajidharma/laravel-admin-core": "^1.0",
- "guzzlehttp/guzzle": "^7.2",
- "laravel/framework": "^10.0",
- "laravel/sanctum": "^3.2",
- "laravel/tinker": "^2.8",
+ "laravel/framework": "^11.0",
+ "laravel/tinker": "^2.9",
"spatie/laravel-permission": "^5.5"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.7",
- "fakerphp/faker": "^1.9.1",
+ "fakerphp/faker": "^1.23",
"laravel/breeze": "^1.7",
"laravel/dusk": "^7.1",
- "laravel/pint": "^1.0",
- "laravel/sail": "^1.18",
- "mockery/mockery": "^1.4.4",
- "nunomaduro/collision": "^7.0",
- "phpunit/phpunit": "^10.0",
- "spatie/laravel-ignition": "^2.0"
+ "laravel/pint": "^1.13",
+ "laravel/sail": "^1.26",
+ "mockery/mockery": "^1.6",
+ "nunomaduro/collision": "^8.1",
+ "phpunit/phpunit": "^10.5",
+ "spatie/laravel-ignition": "^2.4"
},
"autoload": {
"psr-4": {

Also, update the below package if you have installed

  • laravel/cashier-stripe to ^15.0
  • laravel/passport to ^12.0
  • laravel/sanctum to ^4.0
  • laravel/spark-stripe to ^5.0
  • laravel/telescope to ^5.0

3. Run composer update

We have updated all the dependencies on composer.json. Now is the time to run the composer update

./vendor/bin/sail composer update

I am getting the below error due to the laravel/breeze not supporting Laravel 11.

So, we need to find the latest version of laravel/breeze and add it to the composer.json file

  • laravel/breeze to ^2.0

Now getting the same error forlaravel/dusk

so update Dusk to the latest version

  • laravel/dusk to ^8.0

Again we getting errors, this time on our admin panel supporting packages

So, I am going to include Laravel 11 on both Laravel Menu and Laravel Category packages.

"illuminate/support": "^8.71|^9.0|^10.0|^11.0"

Again, this error is due to the spatie/laravel-permission. I am included spatie/laravel-permission in the application and admin code package.

So, going to remove spatie/laravel-permission and update the latest version of the admin code package.

finally, the composer update worked.

4. Check Laravel Version

To check the Laravel version, run the below command

./vendor/bin/sail artisan -v

//or

./vendor/bin/sail artisan --version

//If you not using sail
php artisan --version

Now our Admin Panel is using the Laravel 11.

5. Updating Sanctum

Now open the application in the browser. It throws the Fatal Error.

We are currently not using the Laravel Sanctum on the Admin Panel. So, I am going to remove the HasApiTokens from the user model.

Laravel 11 no longer supports Laravel Sanctum 3.x. Therefore, you should update your application’s Laravel Sanctum dependency to ^4.0 in your composer.json file.

If you're using Sanctum follow the steps mentioned in the upgrade document.

Now the admin panel is loading without errors

6. Remove Config Files

Taylor has introduced a slimmer config version. So, in Laravel 11 below the config is missing

  • config/broadcasting.php
  • config/cors.php
  • config/hashing.php
  • config/sanctum.php
  • config/view.php

We can publish them manually, with this command

php artisan config:publish

OR

php artisan config:publish --all

So, we deleted the below config files similar to Laravel 11

        deleted:    config/broadcasting.php
deleted: config/cors.php
deleted: config/hashing.php
deleted: config/sanctum.php
deleted: config/view.php

7. Update package.json

Laravel 11 is using the Vite version 5. So, we are going to update the Vite version. Also, we going to add the type to the module on package.json.

Find below the updated package.json file.

diff --git a/package.json b/package.json
index 2effbfc..30feaba 100644
--- a/package.json
+++ b/package.json
@@ -1,20 +1,17 @@
{
"private": true,
+ "type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.2",
- "alpinejs": "^3.4.2",
"autoprefixer": "^10.4.2",
- "axios": "^1.1.2",
- "laravel-vite-plugin": "^0.8.0",
- "lodash": "^4.17.19",
- "postcss": "^8.4.6",
- "postcss-import": "^14.0.1",
+ "axios": "^1.6.4",
+ "laravel-vite-plugin": "^1.0",
"tailwindcss": "^3.2.4",
- "vite": "^4.0.0"
+ "vite": "^5.0"
},
"dependencies": {
"daisyui": "^3.0.0",

We have removed alpinejs, lodash as per Laravel 11 package.json. We need to remove the alpinejs, lodash includes in resources/js/app.js and resources/js/bootstrap.js. After the removal, our app.js and bootstrap.js will have below-slim code.

resources/js/app.js

import './bootstrap';

resources/js/bootstrap.js

import axios from 'axios';
window.axios = axios;

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

Now run the npm update after the npm update run the npm run dev

The fix the below error we need to update the postcss.config.js Because we updated the type as a module.

Add export default on postcss.config.js

export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};

Now our Laravel Admin Panel is upgraded with Laravel 11.

Thank you for reading.

Source : Balaji Dharma (Medium)

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Posts Older Posts Home

Meta

Popular Posts

  • Credit card validation in laravel
      Validation rules for credit card using laravel-validation-rules/credit-card package in laravel Install package laravel-validation-rules/cr...
  • Write API Integrations in Laravel and PHP Projects with Saloon
    Write API Integrations in Laravel and PHP Projects with Saloon Saloon  is a Laravel/PHP package that allows you to write your API integratio...
  • iOS 17 Force Screen Rotation not working on iPAD only
    I have followed all the links on Google and StackOverFlow, unfortunately, I could not find any reliable solution Specifically for iPad devic...
  • C++ in Hindi Introduction
    C ++ का परिचय C ++ एक ऑब्जेक्ट ओरिएंटेड प्रोग्रामिंग लैंग्वेज है। C ++ को Bjarne Stroustrup द्वारा विकसित किया गया था। C ++ में आने से पह...
  • Python AttributeError: 'str' has no attribute glob
    I am trying to look for a folder in a directory but I am getting the error.AttributeError: 'str' has no attribute glob Here's ...

Categories

  • Ajax (26)
  • Bootstrap (30)
  • DBMS (42)
  • HTML (12)
  • HTML5 (45)
  • JavaScript (10)
  • Jquery (34)
  • Jquery UI (2)
  • JqueryUI (32)
  • Laravel (1017)
  • Laravel Tutorials (23)
  • Laravel-Question (6)
  • Magento (9)
  • Magento 2 (95)
  • MariaDB (1)
  • MySql Tutorial (2)
  • PHP-Interview-Questions (3)
  • Php Question (13)
  • Python (36)
  • RDBMS (13)
  • SQL Tutorial (79)
  • Vue.js Tutorial (68)
  • Wordpress (150)
  • Wordpress Theme (3)
  • codeigniter (108)
  • oops (4)
  • php (853)

Social Media Links

  • Follow on Twitter
  • Like on Facebook
  • Subscribe on Youtube
  • Follow on Instagram

Pages

  • Home
  • Contact Us
  • Privacy Policy
  • About us

Blog Archive

  • July (2)
  • September (100)
  • August (50)
  • July (56)
  • June (46)
  • May (59)
  • April (50)
  • March (60)
  • February (42)
  • January (53)
  • December (58)
  • November (61)
  • October (39)
  • September (36)
  • August (36)
  • July (34)
  • June (34)
  • May (36)
  • April (29)
  • March (82)
  • February (1)
  • January (8)
  • December (14)
  • November (41)
  • October (13)
  • September (5)
  • August (48)
  • July (9)
  • June (6)
  • May (119)
  • April (259)
  • March (122)
  • February (368)
  • January (33)
  • October (2)
  • July (11)
  • June (29)
  • May (25)
  • April (168)
  • March (93)
  • February (60)
  • January (28)
  • December (195)
  • November (24)
  • October (40)
  • September (55)
  • August (6)
  • July (48)
  • May (2)
  • January (2)
  • July (6)
  • June (6)
  • February (17)
  • January (69)
  • December (122)
  • November (56)
  • October (92)
  • September (76)
  • August (6)

Loading...

Laravel News

Loading...

Copyright © CoderFunda | Powered by Blogger
Design by Coderfunda | Blogger Theme by Coderfunda | Distributed By Coderfunda