<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Chidiebere Chukwudi</title>
    <description>The latest articles on Forem by Chidiebere Chukwudi (@jovialcore).</description>
    <link>https://forem.com/jovialcore</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F53155%2Fe435aad2-af32-4f5b-b912-23e9cbf6fe25.jpg</url>
      <title>Forem: Chidiebere Chukwudi</title>
      <link>https://forem.com/jovialcore</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/jovialcore"/>
    <language>en</language>
    <item>
      <title>'php artisan optimize:clear' might not always work</title>
      <dc:creator>Chidiebere Chukwudi</dc:creator>
      <pubDate>Tue, 08 Apr 2025 01:33:20 +0000</pubDate>
      <link>https://forem.com/jovialcore/php-artisan-optimzeclear-might-not-always-work-5boi</link>
      <guid>https://forem.com/jovialcore/php-artisan-optimzeclear-might-not-always-work-5boi</guid>
      <description>&lt;p&gt;&lt;code&gt;php artisan optimze:clear&lt;/code&gt; might look like it cleared everything...hol' up...For example,  if you run into route issues where you are sure that you are using right the route but getting an error, you are better off running &lt;code&gt;php artisan route:clear&lt;/code&gt; than the one shot &lt;code&gt;php artisan optimize:clear&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Conclusion, most times or for a serious debugging in your laravel application, clearing the specific  cached resources  can tremedously be of help. &lt;/p&gt;

&lt;p&gt;Hope this helps. &lt;/p&gt;

</description>
      <category>php</category>
      <category>laravel</category>
    </item>
    <item>
      <title>BuilderStreak: How Streak timeline Works</title>
      <dc:creator>Chidiebere Chukwudi</dc:creator>
      <pubDate>Sat, 07 Dec 2024 09:31:12 +0000</pubDate>
      <link>https://forem.com/jovialcore/builderstreak-how-streak-timeline-works-3if6</link>
      <guid>https://forem.com/jovialcore/builderstreak-how-streak-timeline-works-3if6</guid>
      <description>&lt;h3&gt;
  
  
  How It Works
&lt;/h3&gt;

&lt;p&gt;Your streak on &lt;a href="//builderstreak.com"&gt;builderstreak.com&lt;/a&gt; has a &lt;strong&gt;start date&lt;/strong&gt; and an &lt;strong&gt;end date&lt;/strong&gt;. For example, when you commit to a 7-day streak, we track your progress starting from the &lt;strong&gt;start date&lt;/strong&gt; (e.g., December 7, 2024) and ending on the &lt;strong&gt;end date&lt;/strong&gt; (e.g., December 14, 2024). That's your window to build, share, and inspire.&lt;/p&gt;

&lt;p&gt;We follow along using the &lt;strong&gt;#buildInPublic&lt;/strong&gt; hashtag to keep an eye on your trail of progress (your tweets). Once your streak ends, we stop monitoring your updates. But don't worry—the footprints you've left behind are yours to revisit and celebrate!&lt;/p&gt;

&lt;p&gt;Cheers. &lt;/p&gt;

</description>
      <category>webdev</category>
    </item>
    <item>
      <title>Why my test-webhook-auto-syncer idea won't work</title>
      <dc:creator>Chidiebere Chukwudi</dc:creator>
      <pubDate>Fri, 20 Sep 2024 19:09:48 +0000</pubDate>
      <link>https://forem.com/jovialcore/why-my-test-webhook-auto-syncer-idea-wont-work-5fl1</link>
      <guid>https://forem.com/jovialcore/why-my-test-webhook-auto-syncer-idea-wont-work-5fl1</guid>
      <description>&lt;h2&gt;
  
  
  Automating Stripe test Webhook Setup with ngrok
&lt;/h2&gt;

&lt;p&gt;Wait,...before you continue reading, I feel the idea is cool and like every modern problem, there could be possible solutions around them but yeah, I didn't budget that time. BECAUSE I THOUGHT IT WOULD BE A QUICK ONE. haha. &lt;/p&gt;

&lt;p&gt;Let's go....&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem statement
&lt;/h2&gt;

&lt;p&gt;As someone who has been working with Stripe API heavily, there's this repetitive task I intended to automate which is setting up test webhook URLs generated by ngrok every time I start my codebase.  &lt;a href="https://github.com/jovialcore/tests-webhook-auto-syncer" rel="noopener noreferrer"&gt;Github repo&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  The 'tedious' flow:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;run ngrok http 8000 &lt;/li&gt;
&lt;li&gt;copy the generated https URL &lt;/li&gt;
&lt;li&gt;login to Stripe dashboard &lt;/li&gt;
&lt;li&gt;create/edit a Stripe webhook&lt;/li&gt;
&lt;li&gt;add Stripe events to listen to&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Automated version:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;signup and login to webhookautosyncer dot com then press one ultimate button (deploy stripe webhook)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fci6axb8o1qamj1nhpuov.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fci6axb8o1qamj1nhpuov.png" alt="webhook" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a more detailed way: &lt;br&gt;
Auto deploy test webhooks to Stripe dashboard for Stripe payments.&lt;br&gt;
🐥 No need to manually add test webhook endpoints (e.g. the ones generated with ngrok) in Stripe dashboard every time you restart your application.&lt;br&gt;
🐥 Just start your app locally, a secured endpoint is automatically generated for you and it is automatically set in your Stripe dashboard.&lt;br&gt;
🐥 It should just work in one click.&lt;/p&gt;
&lt;h2&gt;
  
  
  What should work, I mean, theoritically:
&lt;/h2&gt;

&lt;p&gt;Once you have ngrok running in the background:&lt;br&gt;
The script makes a GET request to &lt;code&gt;http://localhost:4040/api/tunnels/command_line&lt;/code&gt; &lt;br&gt;
Extracts the https URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ngrokUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'public_url'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using &lt;a href="https://docs.stripe.com/api/webhook_endpoints/create?lang=node" rel="noopener noreferrer"&gt;Stripe webhook API&lt;/a&gt;, the webhook will be automatically deployed to users' Stripe dashboard.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$stripe&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;StripeClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"sk_test_YOUR_STRIPE_TEST_KEY"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$stripe&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;webhookEndpoints&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="s1"&gt;'enabled_events'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'charge.succeeded'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'charge.failed'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="s1"&gt;'url'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;  &lt;span class="nv"&gt;$ngrokUrl&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;"/api/v1/webhook/settle-customer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Well,... them challenges:
&lt;/h2&gt;

&lt;p&gt;You can't remotely access people's CLI esp from the browser: If this was possible, that's a big security flaw so the principalities of software architecture and custodians of the internet made this impossible --which is a good thing tbh. &lt;/p&gt;

&lt;p&gt;I could get the ngrok https URL via a localhost but I am unable to do that because, again, I can't make a GET request to localhost from a remote server.&lt;/p&gt;

&lt;p&gt;Lastly, I could write a Node.js CLI tool that, when users install it (globally), this script sends me (my remote server) the ngrok https URL, which I will use to automatically setup a Stripe webhook. Also, I will need to authorize users with an API key kinda. That's like a couple of overheads that I did not budget time for. &lt;/p&gt;

&lt;h2&gt;
  
  
  Solutions (but, I will leave you to try 🤭 ):
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Local App Setup:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Build it as an application one can setup on their own PC.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Distribute the solution as a package. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build it as a Laravel package&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;p&gt;I had fun digging the ngrok API docs and doing research, trying possible approaches but yeah,...here we are. It was a good one. &lt;/p&gt;

&lt;p&gt;Can I have a word?&lt;br&gt;
If you feel you can crack this thing, maybe using another approach, that's super cool. Do let us know!&lt;/p&gt;




&lt;p&gt;I have a &lt;a href="https://x.com/jovial_core/status/1835700098786881912" rel="noopener noreferrer"&gt;recent announcement&lt;/a&gt; you want to check out. &lt;br&gt;
Check me out on GitHub. I got some open source projects going on there: &lt;a href="https://github.com/jovialcore" rel="noopener noreferrer"&gt;https://github.com/jovialcore&lt;/a&gt;.&lt;br&gt;
Cheers to hacking stuff. ⚒️ 🥂&lt;/p&gt;

</description>
      <category>code</category>
      <category>npm</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Integrating Netlify Frontend with External Backend Using Custom DNS Configuration.</title>
      <dc:creator>Chidiebere Chukwudi</dc:creator>
      <pubDate>Fri, 23 Aug 2024 23:12:30 +0000</pubDate>
      <link>https://forem.com/jovialcore/integrating-netlify-frontend-with-external-backend-using-custom-dns-configuration-3l11</link>
      <guid>https://forem.com/jovialcore/integrating-netlify-frontend-with-external-backend-using-custom-dns-configuration-3l11</guid>
      <description>&lt;p&gt;Hi there 👋, I put this piece together because this was me trying to host a frontend project on Netlify then host the backend on a different platform while using a primary domain for the FE (frontendapp.com) and a subdomain for backend API (backend.frontendapp.com)--Remember I said that backend is hosted on another platform too!&lt;/p&gt;

&lt;p&gt;Please read on...😄&lt;/p&gt;

&lt;p&gt;When you deploy an app on Netlify, Netlify generates a custom URL that you can use, e.g., gibberish-gibberish.netlify.com... Netlify also allows you to attach a 'real' domain to this custom domain so your frontend app is exposed to a primary domain.&lt;/p&gt;

&lt;p&gt;For your attached primary domain to work properly, you will have to point to Netlify DNS in the custom nameservers section of the primary domain account, in my case, Namecheap.&lt;/p&gt;

&lt;p&gt;Now, if I do this (point my DNS to Netlify), my subdomain (backend domain) will be affected. I mean, it will not work because my backend is hosted on another hosting platform.&lt;/p&gt;

&lt;p&gt;So we have a problem: FE (frontend) URL works but backend doesn't work because using Netlify DNS as a nameserver for my primary domain will also affect the subdomain too.&lt;/p&gt;

&lt;p&gt;You want to ask: why not host the backend on Netlify? Netlify only hosts static files and on top of that, my backend is PHP/Laravel. I hope we are getting somewhere 👀? Walk with me.&lt;/p&gt;

&lt;p&gt;So how did I tackle this issue? It's simple. I switched to using the basic DNS config for my primary domain.&lt;/p&gt;

&lt;p&gt;Let me explain in detail....&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring DNS For The Frontend
&lt;/h2&gt;

&lt;p&gt;So in my DNS record settings via the advanced section, I added an &lt;code&gt;ALIAS Record&lt;/code&gt; and set the host to &lt;code&gt;@&lt;/code&gt; then pointed the record to Netlify's load balancer which is &lt;code&gt;apex-loadbalancer.netlify.com&lt;/code&gt;&lt;br&gt;
&lt;a href="https://docs.netlify.com/domains-https/custom-domains/configure-external-dns/#configure-an-apex-domain" rel="noopener noreferrer"&gt;Netlify's doc reference&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpyuh9oeg49p5pfu0gn8c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpyuh9oeg49p5pfu0gn8c.png" alt="External DNS CONFIGURATION" width="800" height="57"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One more thing,&lt;br&gt;
After the domain system for the configuration was properly propagated, I got this error:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh6t8vu7zwu06ps4w0ewi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh6t8vu7zwu06ps4w0ewi.png" alt="default netlify error page" width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Site Not Found&lt;/code&gt;. This in itself is good news. You know why? It means that the domain configuration works but it happened that I still had an old Netlify DNS setup. So the solution will be to delete the former DNS entries from my Netlify account so the external DNS configuration can work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring DNS Record for Backend
&lt;/h2&gt;

&lt;p&gt;For our backend which is a subdomain for the API deployment on another hosting platform, I created some DNS records for that too.&lt;br&gt;
I set the Record type to &lt;code&gt;A record&lt;/code&gt; then set host as subdomain name (e.g., backend) let it point to the platform's IP address.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F61crmzqbk74mrfu6x9gd.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F61crmzqbk74mrfu6x9gd.jpeg" alt="backend dns record setup" width="800" height="80"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the following, I was good.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Now I have my FE hosted on Netlify with some perks like auto deployment, GitHub PR preview URLs, etc., which uses the primary domain (e.g., frontendapp.com) while I conveniently have my API on another platform that uses a subdomain (backend.frontendapp.com). All managed with the DNS configurations mentioned above.&lt;/p&gt;

&lt;p&gt;Thanks for reading through. If you do have any questions, do let me know.&lt;/p&gt;

&lt;p&gt;Between, I have an open source app I am maintaining with my friends, &lt;a href="//whatcompanystack.com"&gt;whatcompanystack.com&lt;/a&gt;. Where we are trying to see how we can contribute our quota to the African tech startup ecosystem. &lt;a href="//whatcompanystack.com"&gt;whatcompanystack.com&lt;/a&gt; lists African startups and their tech stacks. You can use this to get insight into what tech stacks some startups use, etc. &lt;a href="https://github.com/jovialcore" rel="noopener noreferrer"&gt;It is opensource&lt;/a&gt;. You should take a look.&lt;/p&gt;

</description>
      <category>netlify</category>
      <category>dns</category>
      <category>backend</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Using Bootstrap 5 with NUXT 3</title>
      <dc:creator>Chidiebere Chukwudi</dc:creator>
      <pubDate>Wed, 10 Apr 2024 11:03:57 +0000</pubDate>
      <link>https://forem.com/jovialcore/using-bootstrap-5-with-nuxt-3-3ecj</link>
      <guid>https://forem.com/jovialcore/using-bootstrap-5-with-nuxt-3-3ecj</guid>
      <description>&lt;p&gt;Nuxt js is an amazing addition to the vuejs ecosystem in a couple of ways. One of them is it's usefulness in handling SEO related issues while giving you the privilege of creating a full-stack web application in regular vue with robust server side rendering support. &lt;/p&gt;

&lt;p&gt;In this tutorial, we are going to be looking at a straight forward demonstration of how to use boostrap 5 with nuxt. &lt;/p&gt;

&lt;h3&gt;
  
  
  Create a Nuxt App
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;npx&lt;/span&gt; &lt;span class="nx"&gt;nuxi&lt;/span&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;latest&lt;/span&gt; &lt;span class="nx"&gt;init&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;project&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Install Bootstrap and other dependencies
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;As of the time of writing this article, latest version of bootstrap is bootstrap 5.3.3&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i bootstrap@5.3.3 

npm i sass &lt;span class="nt"&gt;-D&lt;/span&gt;

npm i sass-loader &lt;span class="nt"&gt;-D&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Setting up
&lt;/h3&gt;

&lt;p&gt;In your newly created nuxt app, at the file root, create a &lt;code&gt;plugins&lt;/code&gt; folder. We are creating the plugins folder because we are going to be installing boostrap 5 as a &lt;a href="https://nuxt.com/docs/guide/directory-structure/plugins"&gt;nuxt plugin&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Next, inside the plugins folder, create a &lt;code&gt;useBootstrap.client.ts&lt;/code&gt; and register the boostrap as a nuxt plugin:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;bootstrap&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bootstrap&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineNuxtPlugin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nuxtApp&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;provide&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;bootstrap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;bootstrap&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, we create a &lt;code&gt;assets&lt;/code&gt; folder. This folder is where bundlers like vite look at to bundle assets. In this folder, create a &lt;code&gt;main.scss&lt;/code&gt; file then import bootstrap's scss.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nt"&gt;main&lt;/span&gt;&lt;span class="nc"&gt;.scss&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s2"&gt;'bootstrap/scss/bootstrap'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, to include bootstrap styling in all of your pages, we will be referencing its path and Nuxt will include it to all the pages of your application.&lt;/p&gt;

&lt;p&gt;Open &lt;code&gt;nuxt.config.ts&lt;/code&gt; that is located at the root folder and add the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// https://nuxt.com/docs/api/configuration/nuxt-config &lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineNuxtConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;devtools&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;enabled&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="na"&gt;css&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;~/assets/main.scss&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Testing
&lt;/h4&gt;

&lt;p&gt;To see bootstrap styling in action, lets create a typical button element and apply bootstrap class. Edit your &lt;code&gt;app.vue&lt;/code&gt; :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
//app.vue

&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt; Using  boostrap 5 with Nuxt  &lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"btn btn-primary"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; share  &lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fleusxrsy36j6p0vne8n0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fleusxrsy36j6p0vne8n0.png" alt="bootstrap with nuxt " width="675" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading. Let me know if you have any feedback or comment in the comment section.&lt;/p&gt;

&lt;p&gt;Find me on X(Formerly Twitter ) : &lt;a href="https://twitter.com/jovial_core"&gt;jovial_core&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Linkedin: &lt;a href="https://www.linkedin.com/in/chidieberechukwudi"&gt;Chidiebere Chukwudi&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cover image credits:  &lt;a href="https://www.pexels.com/photo/ceramic-objects-on-a-white-background-8356902/"&gt;Photo by Marina M: &lt;/a&gt;&lt;/p&gt;

</description>
      <category>nuxt</category>
      <category>bootstrap</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Media uploads to Azure blob storage: the REST API Way in Laravel/PHP.</title>
      <dc:creator>Chidiebere Chukwudi</dc:creator>
      <pubDate>Sat, 23 Mar 2024 14:37:21 +0000</pubDate>
      <link>https://forem.com/jovialcore/media-uploads-to-azure-blob-storage-the-rest-api-way-in-laravelphp-pf5</link>
      <guid>https://forem.com/jovialcore/media-uploads-to-azure-blob-storage-the-rest-api-way-in-laravelphp-pf5</guid>
      <description>&lt;p&gt;Hi there, I hope you're doing well. Firstly, this tutorial is somewhat Laravel-specific, but I assure you that you can apply the approach outlined here with vanilla PHP or any PHP framework you prefer. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Azure/azure-sdk-for-php?tab=readme-ov-file#microsoft-azure-sdk-for-php" rel="noopener noreferrer"&gt;Microsoft retired&lt;/a&gt; the PHP Azure Storage SDK, which means there will be no maintenance. So, if this is a concern for you, you may want to consider trying the REST API approach.&lt;/p&gt;

&lt;p&gt;In this article, we are going to quickly highlight how you can upload images, videos or any media file to Azure using Azure Blob Storage REST API. &lt;/p&gt;

&lt;p&gt;For sheer simplicity of a simple tutorial, let's just have a php method to put our logic and send a request to azure.&lt;/p&gt;

&lt;p&gt;Like every normal PaaS out there, we will need some basic credentials to  authorize access to the azure blob upload service.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://learn.microsoft.com/en-us/azure/storage/common/storage-account-keys-manage?tabs=azure-portal#view-account-access-keys" rel="noopener noreferrer"&gt; Login in to your azure portal to get these credentials&lt;/a&gt; and also &lt;a href="https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-portal#create-a-container" rel="noopener noreferrer"&gt;create a container&lt;/a&gt; then  replace the placeholders in the following code with your credentials. &lt;/p&gt;

&lt;p&gt;Typically, you want to protect these credentials by fetching them from your &lt;code&gt;.env&lt;/code&gt; file. It's ideal not to hardcode your credentials.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;uploadToAzureCloud&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="nv"&gt;$storageAccountName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'services.azure_storage.account_name'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
     &lt;span class="nv"&gt;$containerName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'services.azure_storage.container'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nv"&gt;$accessKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'services.azure_storage.key'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the following code, we want to ensure that the request has a file. Then, we obtain the original filename, create a hashed variant for the filename that we are going to use as our blob name, and also obtain the file size.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;
&lt;span class="c1"&gt;// the previous code&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;hasFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'file'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

 &lt;span class="nv"&gt;$file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'file'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="nv"&gt;$orignalFileName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getClientOriginalName&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
 &lt;span class="nv"&gt;$mimeType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getMimeType&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
 &lt;span class="nv"&gt;$blobName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;  &lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;hashName&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nv"&gt;$fileSize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;filesize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;


&lt;span class="c1"&gt;//the upcoming code&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Constructing an Azure Blob Signature
&lt;/h4&gt;

&lt;p&gt;Next up is constructing an azure blob signature. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A Shared Access Signature (SAS) is a security token that provides restricted access to certain resources in cloud-based storage services, such as Azure Blob storage or Azure File storage. SAS enables secure and controlled access to these resources without exposing the account's access keys or credentials.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A SaS token or signature is a string that azure demands that lets us make upload media files. The following code, generates SaS token.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;
&lt;span class="nv"&gt;$dateTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;gmdate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'D, d M Y H:i:s \G\M\T'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="nv"&gt;$urlResource&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"/&lt;/span&gt;&lt;span class="nv"&gt;$storageAccountName&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;$containerName&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;$blobName&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$headerResource&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"x-ms-blob-cache-control:max-age=3600&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;x-ms-blob-type:BlockBlob&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;x-ms-date:&lt;/span&gt;&lt;span class="nv"&gt;$dateTime&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;x-ms-version:2019-12-12"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Generate signature&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;                     &lt;span class="c1"&gt;// initiate an empty array (don't remove this 🙂)&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'PUT'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;               &lt;span class="cm"&gt;/*HTTP Verb*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/*Content-Encoding*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/*Content-Language*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$fileSize&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;           &lt;span class="cm"&gt;/*Content-Length (include value when zero)*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/*Content-MD5*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$mimeType&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;         &lt;span class="cm"&gt;/*Content-Type*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/*Date*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/*If-Modified-Since */&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/*If-Match*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/*If-None-Match*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/*If-Unmodified-Since*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/*Range*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$headerResource&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="cm"&gt;/*CanonicalizedHeaders*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$urlResource&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;        &lt;span class="cm"&gt;/*CanonicalizedResource*/&lt;/span&gt;


&lt;span class="c1"&gt;// converts the array to a string as required by MS &lt;/span&gt;
&lt;span class="nv"&gt;$str2sign&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;implode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;


&lt;span class="nv"&gt;$sig&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;base64_encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;hash_hmac&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'sha256'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;utf8_encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$str2sign&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nb"&gt;base64_decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$accessKey&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your major focus should be on the &lt;code&gt;$sig&lt;/code&gt; variable that holds the final outcome of the sas token construct. Take note of the &lt;code&gt;content-Type&lt;/code&gt; comment: you can adjust this field with your desired content type.Now with the SaS token signature covered, we can now make our REST API call. &lt;/p&gt;

&lt;h3&gt;
  
  
  Uploading media file
&lt;/h3&gt;

&lt;p&gt;We are making use of guzzle for the API request.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;$url&lt;/code&gt; variable we will be making the request to is in this format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="s2"&gt;"https://&amp;lt;AzureStorageName&amp;gt;.blob.core.windows.net/&amp;lt;containerName&amp;gt;/&amp;lt;blobName&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The HTTP verb to use is "PUT" followed by a header construct to pass certain header values like Authorization, etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;
&lt;span class="c1"&gt;// the previous code&lt;/span&gt;

&lt;span class="nv"&gt;$url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://&lt;/span&gt;&lt;span class="nv"&gt;$storageAccountName&lt;/span&gt;&lt;span class="s2"&gt;.blob.core.windows.net/&lt;/span&gt;&lt;span class="nv"&gt;$containerName&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;$blobName&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;span class="c1"&gt;// use GuzzleHttp\Client;&lt;/span&gt;

&lt;span class="nv"&gt;$client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nv"&gt;$response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$client&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'PUT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
&lt;span class="s1"&gt;'headers'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
   &lt;span class="s1"&gt;'Authorization'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$authHeader&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="s1"&gt;'x-ms-blob-cache-control'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'max-age=3600'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="s1"&gt;'x-ms-blob-type'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'BlockBlob'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="s1"&gt;'x-ms-date'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$dateTime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="s1"&gt;'x-ms-version'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'2019-12-12'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="s1"&gt;'Content-Type'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$mimeType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="s1"&gt;'Content-Length'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$fileSize&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
     &lt;span class="s1"&gt;'body'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;fopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="s1"&gt;'r'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;]);&lt;/span&gt;

&lt;span class="c1"&gt;//the next code up coming &lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Of course, we assigned a body to the put request. The body contains the actual file that we are trying to upload to azure. &lt;/p&gt;

&lt;h4&gt;
  
  
  Generating a url for our uploaded image.
&lt;/h4&gt;

&lt;p&gt;If our upload is successful, Azure Blob Storage API sends a &lt;code&gt;200&lt;/code&gt; response status code. If we confirm that our request is successful, we need to generate a media url to use in displaying images on the frontend. &lt;/p&gt;

&lt;p&gt;To make sure we get a proper url that should work, we will generate a sas token from azure dashboard. This sas token is what will we use as our &lt;code&gt;$mediaUrlSasToken&lt;/code&gt; . &lt;a href="https://learn.microsoft.com/en-us/azure/data-explorer/kusto/api/connection-strings/generate-sas-token#azure-portal" rel="noopener noreferrer"&gt; Follow the steps mentioned in this Azure guide to generate one&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An example of interface to generate a Sas Token &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh76jpvqsacvpppp4cdyk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh76jpvqsacvpppp4cdyk.png" alt="An example of interface to generate a Sas Token" width="800" height="699"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once we have the the token, replace the token with the placeholder assigned to &lt;code&gt;$urlSasToken&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getStatusCode&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;201&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// image sas token &lt;/span&gt;
&lt;span class="nv"&gt;$urlSasToken&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'generated_sas_token'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;response&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="s1"&gt;'original_name'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$originalFIleName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s1"&gt;'media_url'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$url&lt;/span&gt;&lt;span class="s2"&gt;?&lt;/span&gt;&lt;span class="nv"&gt;$urlSasToken&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;response&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;json&lt;/span&gt; &lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'message'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'Something went wrong'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
       &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Result
&lt;/h4&gt;

&lt;p&gt;A successful request (&lt;code&gt;201&lt;/code&gt; status code) will look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5hn87elvwqkgzysua4pk.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5hn87elvwqkgzysua4pk.jpeg" alt="From " width="800" height="82"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The full composite of the &lt;code&gt;$mediaUrl&lt;/code&gt; is as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="s2"&gt;"https://&amp;lt;AzureStorageName&amp;gt;.blob.core.windows.net/&amp;lt;containerName&amp;gt;/&amp;lt;blobName&amp;gt;?&amp;lt;urlSasToken&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Complete Code:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;uploadToAzureCloud&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="nv"&gt;$storageAccountName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'services.azure_storage.account_name'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
     &lt;span class="nv"&gt;$containerName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'services.azure_storage.container'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nv"&gt;$accessKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'services.azure_storage.key'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;hasFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'file'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

     &lt;span class="nv"&gt;$file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'file'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

     &lt;span class="nv"&gt;$orignalFileName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getClientOriginalName&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

     &lt;span class="nv"&gt;$mimeType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getMimeType&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

     &lt;span class="nv"&gt;$blobName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;  &lt;span class="s1"&gt;'folder/'&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;hashName&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

     &lt;span class="nv"&gt;$fileSize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;filesize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

     &lt;span class="nv"&gt;$dateTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;gmdate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'D, d M Y H:i:s \G\M\T'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

     &lt;span class="nv"&gt;$urlResource&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"/&lt;/span&gt;&lt;span class="nv"&gt;$storageAccountName&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;$containerName&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;$blobName&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nv"&gt;$headerResource&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"x-ms-blob-cache-control:max-age=3600&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;x-ms-blob-type:BlockBlob&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;x-ms-date:&lt;/span&gt;&lt;span class="nv"&gt;$dateTime&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;x-ms-version:2019-12-12"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

                &lt;span class="c1"&gt;// Generate signature&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;  &lt;span class="c1"&gt;// initiate an empty array (don't remove this 🙂)&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'PUT'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;               &lt;span class="cm"&gt;/*HTTP Verb*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/*Content-Encoding*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/*Content-Language*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$fileSize&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;           &lt;span class="cm"&gt;/*Content-Length (include value when zero)*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/*Content-MD5*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$mimeType&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;         &lt;span class="cm"&gt;/*Content-Type*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/*Date*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/*If-Modified-Since */&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/*If-Match*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/*If-None-Match*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/*If-Unmodified-Since*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/*Range*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$headerResource&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="cm"&gt;/*CanonicalizedHeaders*/&lt;/span&gt;
&lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$urlResource&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;        &lt;span class="cm"&gt;/*CanonicalizedResource*/&lt;/span&gt;


  &lt;span class="c1"&gt;// converts the array to a string as required by MS &lt;/span&gt;
    &lt;span class="nv"&gt;$str2sign&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;implode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$arraysign&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nv"&gt;$sig&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;base64_encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;hash_hmac&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'sha256'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;utf8_encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$str2sign&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nb"&gt;base64_decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$accessKey&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="nv"&gt;$url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://&lt;/span&gt;&lt;span class="nv"&gt;$storageAccountName&lt;/span&gt;&lt;span class="s2"&gt;.blob.core.windows.net/&lt;/span&gt;&lt;span class="nv"&gt;$containerName&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;$blobName&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


           &lt;span class="c1"&gt;// use GuzzleHttp\Client;&lt;/span&gt;

     &lt;span class="nv"&gt;$client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nv"&gt;$response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$client&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'PUT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
   &lt;span class="s1"&gt;'headers'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'Authorization'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"SharedKey &lt;/span&gt;&lt;span class="nv"&gt;$storageAccountName&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="nv"&gt;$sig&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'x-ms-blob-cache-control'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'max-age=3600'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'x-ms-blob-type'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'BlockBlob'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'x-ms-date'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$dateTime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'x-ms-version'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'2019-12-12'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'Content-Type'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$mimeType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'Content-Length'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$fileSize&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
       &lt;span class="s1"&gt;'body'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;fopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="s1"&gt;'r'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
     &lt;span class="p"&gt;]);&lt;/span&gt;          
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getStatusCode&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;201&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="c1"&gt;// image sas token &lt;/span&gt;
  &lt;span class="nv"&gt;$urlSasToken&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'services.azure_storage.sas_token'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;
        &lt;span class="p"&gt;[&lt;/span&gt;
          &lt;span class="s1"&gt;'original_name'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;   &lt;span class="nv"&gt;$orignalFileName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="s1"&gt;'media_url'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$url&lt;/span&gt;&lt;span class="s2"&gt;?&lt;/span&gt;&lt;span class="nv"&gt;$urlSasToken&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="p"&gt;];&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;response&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'message'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'Something went wrong'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
           &lt;span class="p"&gt;}&lt;/span&gt;
       &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;RequestException&lt;/span&gt; &lt;span class="nv"&gt;$e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="c1"&gt;// If there's an error, log the error message&lt;/span&gt;
    &lt;span class="nv"&gt;$errorMessage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$e&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getMessage&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;response&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'error'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$errorMessage&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Final Thoughts:
&lt;/h4&gt;

&lt;p&gt;This is a REST API approach to uploading media and generating a media url to display the uploaded resource.  You can organised your code properly into separate methods or have some blocks like &lt;code&gt;.env&lt;/code&gt; configurations in a separate class or however you want. &lt;/p&gt;

&lt;p&gt;Thanks for reading, I hope you do find this resource useful.&lt;/p&gt;

&lt;p&gt;Find me on X(Formerly Twitter ) : &lt;a href="https://twitter.com/jovial_core" rel="noopener noreferrer"&gt;jovial_core&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, you can checkout &lt;a href="https://github.com/jovialcore" rel="noopener noreferrer"&gt;what-company-stack 1.0 &lt;/a&gt;, an open source project we released earlier this year. &lt;/p&gt;

&lt;p&gt;If you don't mind, there is a sponsorship button on &lt;a href="https://github.com/sponsors/jovialcore" rel="noopener noreferrer"&gt; my github profile &lt;/a&gt; 😊&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.pexels.com/photo/motor-boat-making-circle-on-water-surface-6785289/" rel="noopener noreferrer"&gt;Cover Photo by Sanat Anghan&lt;/a&gt; &lt;/p&gt;

</description>
      <category>azure</category>
      <category>php</category>
      <category>laravel</category>
      <category>restapi</category>
    </item>
    <item>
      <title>Prepare for Google Summer Of Code 2025: Tips and Takes</title>
      <dc:creator>Chidiebere Chukwudi</dc:creator>
      <pubDate>Sat, 06 Jan 2024 13:16:06 +0000</pubDate>
      <link>https://forem.com/jovialcore/prepare-for-google-summer-of-code-2024-tips-and-takes-1k76</link>
      <guid>https://forem.com/jovialcore/prepare-for-google-summer-of-code-2024-tips-and-takes-1k76</guid>
      <description>&lt;h3&gt;
  
  
  What is Google Summer of Code?
&lt;/h3&gt;

&lt;p&gt;Google Summer of Code (GSoC) is a paid remote open-source program that provides individuals with the opportunity to contribute to  open-source projects. On a 12+ week timeline, GSoC Contributors work with an open source organization on a programming project under the guidance of mentors. Participants receive a stipend during the course of the program.&lt;/p&gt;

&lt;p&gt;Google Summer of Code initially started off as a type that only considered students or university undergraduates in 2005, not until 2022 when Google announced that it is going to open the program to contributors new to open-source software development and not just to students anymore.&lt;/p&gt;

&lt;h3&gt;
  
  
  Who is Eligible?
&lt;/h3&gt;

&lt;p&gt;If you are someone who is starting out in tech, familiar with any programming language and want to gain more experience while being supervised by mentors; or you are the type with some experience but a beginner in the open source field and want the opportunity of contributing to a large project while gaining experience on real-world software development projects that will be used by thousands or millions of people? Then you are not far from home; you are welcome to participate.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You are eligible if you have not been accepted into Google Summer of Code more than twice. 👀&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Must be at least 18 years old at the time of registration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You must not reside in a country that is not currently embargoed by the United States.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You must be eligble to work in the country for which you reside in.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For more information on GSoC Contributor eligibility, click &lt;a href="https://summerofcode.withgoogle.com/terms/contributor" rel="noopener noreferrer"&gt;here&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Aim And Objective Of Google Summer Of Code
&lt;/h3&gt;

&lt;p&gt;According to the Google Open Source team, the aim of the program is to give people the opportunity to come on board open source organizations, especially bringing new contributors into open source communities that are centered around mentorship and collaboration. &lt;/p&gt;

&lt;p&gt;The hope is that these GSoC Contributors will become passionate about the communities they are part of during the program and continue to actively contribute to these communities or even start their own open-source projects even after the GSoC program ends.&lt;/p&gt;

&lt;p&gt;A favorite quote from Drupal:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;”Let them come for the code and stay for the community”&lt;/em&gt; 😁&lt;/p&gt;

&lt;p&gt;Now let’s get to the interesting part…&lt;/p&gt;

&lt;h3&gt;
  
  
  Choosing an Organization and Application Process
&lt;/h3&gt;

&lt;p&gt;You have the choice to pick any organizations you want to contribute to.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9hvbimveqlfwgfk4n1xk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9hvbimveqlfwgfk4n1xk.png" alt="Image description" width="800" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You may choose an organization on the basis that  the organization belongs to a niche that appeals to you, say it’s security, databases, etc, or you might choose an organization because you are familiar with one or more technologies they use, such as looking at organizations with JavaScript, PHP, or GO projects, etc. However, it does not mean that you must know all the technologies listed on an organization’s page.&lt;/p&gt;

&lt;p&gt;Choosing an organization is very important as it decides the technologies you will be using, the project, and the people you will be working with. To add to what I mentioned earlier, you can form your decisions around the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What are your professional interests or areas of focus?&lt;/li&gt;
&lt;li&gt;What open-source software have you used and for the love of the software, you want to contribute your own quota.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://summerofcode.withgoogle.com/programs/2024/organizations" rel="noopener noreferrer"&gt;Once GSoC organizers announces organisations&lt;/a&gt; that will be participating in the 2024 cohort, you can simply filter the organizations you want based on the categories that interest you or use the search field to search organizations base on a programming language/framework of your choice.&lt;/p&gt;

&lt;p&gt;If you are settled with an organization of your choice, the next thing you want to do is join the community platform the organization specifies. This can be a Discord server, Slack workspaces, Zulip, etc. So you want to identify with them upon joining like announcing your arrival or something like that 😅. You will be using this platform to communicate with other applicants and mentors or organization management.&lt;/p&gt;

&lt;h3&gt;
  
  
  Get Yourself Ready Ahead of Time
&lt;/h3&gt;

&lt;p&gt;Now, this is very important…,&lt;br&gt;
While you wait for organizations to be officially announced, you want to get yourself familiar with the organization’s community, pick up first issues on their respective GitHub repos and start working on them, create your first pull request starting with good first issues then you move on. &lt;/p&gt;

&lt;p&gt;This proactive approach will give you an edge, increase your visibility and can earn you some points when you reference them in your proposal application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Organization Announcement
&lt;/h3&gt;

&lt;p&gt;Organization announced! What should you do next?&lt;/p&gt;

&lt;p&gt;Each organization announced usually provides project ideas and detailed information about each project idea. Some organizations can have these project details in a document, GitHub readme, etc.&lt;/p&gt;

&lt;p&gt;Project ideas come with some important details like difficulty level (medium, hard, etc),&lt;br&gt;
Medium-size projects have an approximate duration of 175hrs while Large Size Project duration is about 350hrs.&lt;br&gt;
One or more mentors will be assigned to each project idea. Project Ideas look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F859r2o5hunanmph9matm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F859r2o5hunanmph9matm.png" alt="Image description" width="783" height="552"&gt;&lt;/a&gt; &lt;a href="https://gitlab.com/cdli/framework/-/wikis/Google-Summer-of-Code-GSoC-2022-Cuneiform-Digital-Library-Initiative-(CDLI)-ideas-list" rel="noopener noreferrer"&gt;Reference&lt;/a&gt;&lt;br&gt;
The project ideas are specific tasks your organization is expecting you to do, most of which are code-related, and some may involve design.&lt;/p&gt;

&lt;h3&gt;
  
  
  Proposals:
&lt;/h3&gt;

&lt;p&gt;Next thing you want to do is start working on your proposal for a selected project idea.&lt;br&gt;
You will be writing a proposal per project idea that you select. &lt;/p&gt;

&lt;p&gt;Generally, organizations allow you to select more than one project idea to work on but that is left for you to decide. You can also decide to apply to more than one organization (at most three) to spread your chances however, proposal preparation for multiple organizations require some extra commitment.&lt;/p&gt;

&lt;p&gt;What are proposals: a proposal in GSoC context is a detailed explanation of what your selected project idea is all about. This includes detailed information on how you plan to execute that project idea, milestones and deliverables, plus, maybe, brief information about you and why you should be selected. Proposal formats differ with organizations but the information you will include in your proposals could follow this structure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Project idea title and Profile details.&lt;/li&gt;
&lt;li&gt;Project Idea description (In your own words. Showcasing how best you understand the project idea).&lt;/li&gt;
&lt;li&gt;Your solution and approach.&lt;/li&gt;
&lt;li&gt;Deliverables (sub-features/sub-tasks).&lt;/li&gt;
&lt;li&gt;Timeline: This is the speculated timeline for each deliverable for the GSoC period which is by default 12 weeks except your request for a deadline extension with the permission of your mentor.&lt;/li&gt;
&lt;li&gt;Your motivation: Understand “your motivation” more like “why you should be selected?”. Here you want to briefly highlight some of your other experiences in coding or design. If you have a portfolio, a blog or just anything at all, you can highlight them.  You also want to mention why you choose that organization and how you want to be part of that community even after the program ends –borrow that tip from me 😉.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  If you are selected, what do you do?
&lt;/h3&gt;

&lt;p&gt;First of all, congrats 🎉. (Believe it !!! 🔥🤗 ) Post it on your WhatsApp statuses. Share it on LinkedIn and of course, X (formerly Twitter)!!! 🥂 🎊 😂&lt;/p&gt;

&lt;p&gt;Selected participants are usually announced around May or so. However, going forward, you should have an understanding of what to expect. It is worth noting that you will need to pay attention to your emails as that will be the major means of communication between Google Summer of Code organizers  and you. Through these emails, you will be guided properly on each next step you are to take.&lt;/p&gt;

&lt;p&gt;There are about 3 weeks of community bonding before coding starts properly.&lt;br&gt;
During this period, you get to meet with other selected participants. Your meeting dates will be communicated to you and any other organizations’ specific information. See the GSoC 2024 &lt;a href="https://developers.google.com/open-source/gsoc/timeline" rel="noopener noreferrer"&gt;timeline&lt;/a&gt; for more information on dates and timelines.&lt;/p&gt;

&lt;h3&gt;
  
  
  Payment, Stipend?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffg0ixqa3f3rquc8i209q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffg0ixqa3f3rquc8i209q.png" alt="Image description" width="800" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Payment is made through Payoneer–The last time I checked though. I don’t know if the means of payment or platform might change this time. Just make sure you check your emails for guidance when you are selected. The Google open-source team will send you proper details on how to go about payment.&lt;/p&gt;

&lt;p&gt;Stipend is based on the country you currently live in and depends on the duration of your project.&lt;/p&gt;

&lt;p&gt;For example, for a 175hr duration project idea, usually, the payment is typically divided into two phases: $650 (45%) after the first evaluation and then $850 (55%) after the final evaluation. This payment structure spans across 3 months making it $1500 in total for a 175hr project. For more Info about payment, &lt;a href="https://developers.google.com/open-source/gsoc/help/student-stipends" rel="noopener noreferrer"&gt;see full stipend breakdown&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkn1hhqi6mddrzvxz8xs5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkn1hhqi6mddrzvxz8xs5.png" alt="Image description" width="734" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Certification
&lt;/h3&gt;

&lt;p&gt;Will I be given a certificate?&lt;/p&gt;

&lt;p&gt;After the program has ended, usually around September or so, you will be given a certificate of completion and a verification letter from the Google open-source team.&lt;/p&gt;

&lt;h3&gt;
  
  
  Post GSOC
&lt;/h3&gt;

&lt;p&gt;Are there chances of getting hired after the program?&lt;/p&gt;

&lt;p&gt;The answer is YES and NO. It depends on your organization’s decision and sometimes there are situations like that.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Key take-away here is that you should acquaint yourself early enough with any organization you intend to apply to. Start contributing to their codebase or simply familiarize yourself with the organization's projects. Work on your proposal and get along with their community.&lt;/p&gt;

&lt;p&gt;Always keep an eye on &lt;a href="https://summerofcode.withgoogle.com/" rel="noopener noreferrer"&gt;Google Summer Of Code Official Website&lt;/a&gt;.  &lt;/p&gt;

&lt;p&gt;Before you go, here is a recent &lt;a href="https://www.youtube.com/watch?v=7jD2tChhrWM" rel="noopener noreferrer"&gt;GSoC 2022 Introductory video&lt;/a&gt; you can watch to wet your appetite 😉.&lt;/p&gt;

&lt;p&gt;Cheers to joining an open-source community of smart people, working on a great project and making some cash along the way. Congratulations in advance !&lt;/p&gt;

&lt;p&gt;You can reachout to me on X (formerly twitter): &lt;br&gt;
&lt;a href="https://twitter.com/jovial_core" rel="noopener noreferrer"&gt;jovial_core&lt;/a&gt;&lt;br&gt;
Also, you can checkout &lt;a href="https://github.com/jovialcore" rel="noopener noreferrer"&gt;what-company-stack 1.0 &lt;/a&gt;, an open source project we just released. &lt;/p&gt;

</description>
      <category>opensource</category>
      <category>gsoc</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Traits in php--bible perspective</title>
      <dc:creator>Chidiebere Chukwudi</dc:creator>
      <pubDate>Wed, 06 Sep 2023 07:39:24 +0000</pubDate>
      <link>https://forem.com/jovialcore/traits-in-php-bible-perspective-4ja7</link>
      <guid>https://forem.com/jovialcore/traits-in-php-bible-perspective-4ja7</guid>
      <description>&lt;h4&gt;
  
  
  What are traits in php ?
&lt;/h4&gt;

&lt;p&gt;Traits solves the problem where php classes can't inhrerit behaviours or use properties, methods, etc from other classes except the parent class it extends to. &lt;/p&gt;

&lt;p&gt;Traits in php makes a class have access to methods, properties in othe classes. &lt;br&gt;
Let's use the bible story to elaborate this: We are not native  isrealites so by default we as gentile class can't have any inheritance with the jews. But traits (Jesus Christ ) has come to bridge this gap. Take for example :&lt;/p&gt;

&lt;p&gt;The child class, isrealites extends (inherits) from the parent class, God&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;isrealites&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;God&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Gentile class (actually, Gentile Nation) wants to have access to the abrahamic promises but can't. Then Jesus Christ came in for us --Traits !&lt;/p&gt;

&lt;p&gt;So create a trait class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kd"&gt;trait&lt;/span&gt; &lt;span class="nc"&gt;JesusChrist&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;salvationPromise&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"the promise is unto you and to your children, children"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;prosperityPromise&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"I will above all things that thou mayeth prosper even as thy soul prospereth "&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;freedomFromSin&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"If the son shall make you free, you shall be free indeed"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For gentiles to use this trait as well inherit all the  promises, we provide a "Jesus Trait" for them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Gentiles&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;JesusChrist&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nv"&gt;$gentile&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Gentiles&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;//pick one promise &lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$gentile&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;freedomFromSin&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A full code will look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;
&lt;span class="kd"&gt;trait&lt;/span&gt; &lt;span class="nc"&gt;JesusChrist&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;salvationPromise&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"the promise is unto you and to your children, children"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;prosperityPromise&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"I will above all things that thou mayeth prosper even as thy soul prospereth "&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;freedomFromSin&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"If the son shall make you free, you shall be free indeed"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Gentiles&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;JesusChrist&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="nv"&gt;$gentile&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Gentiles&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;//pick one promise &lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$gentile&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;freedomFromSin&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Traits are used to access methods and properties that extend the capabilities of a class. &lt;/p&gt;

&lt;p&gt;More resources to learn from &lt;a href="https://www.php.net/manual/en/language.oop5.traits.php#:~:text=Traits%20are%20a%20mechanism%20for,living%20in%20different%20class%20hierarchies."&gt;PHP DOC&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>wordpress</category>
    </item>
    <item>
      <title>Unlock the power of list: Practical usecase of list() in php.</title>
      <dc:creator>Chidiebere Chukwudi</dc:creator>
      <pubDate>Sun, 06 Aug 2023 14:00:00 +0000</pubDate>
      <link>https://forem.com/jovialcore/unlock-the-power-of-list-practical-usecase-of-list-in-php-52i7</link>
      <guid>https://forem.com/jovialcore/unlock-the-power-of-list-practical-usecase-of-list-in-php-52i7</guid>
      <description>&lt;p&gt;Hi 👋, yet another practical usecase of the "native php function array",  &lt;code&gt;list()&lt;/code&gt;. In this tutorial lets see an example for a likely everyday usecase for you. 👀 Let's go:&lt;/p&gt;

&lt;p&gt;Wait 🙋! &lt;code&gt;List()&lt;/code&gt; is not an array function but a &lt;a href="https://chat.openai.com/share/e56766cf-7c5e-4bac-8845-7bbe347afacf"&gt;language construct&lt;/a&gt; More like reserved keywords that have specific meaning and are used to define the structure and behaviour of code. Reason why I had the quotes in my intro. lol&lt;/p&gt;

&lt;p&gt;Enough. Lets get to business, shall we ?! 🤗&lt;/p&gt;

&lt;p&gt;So what is a &lt;code&gt;List()&lt;/code&gt; ?&lt;br&gt;
&lt;code&gt;List()&lt;/code&gt; is used to assign values to a list of variables at once or in a single operation.It provides a convenient way to extract values from an array and assign them to individual variables in one go. You will find &lt;code&gt;list()&lt;/code&gt; to be used mostly with arrays.  Let's see an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$countries&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Nigeria'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Canada'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Lithuania'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="c1"&gt;// we want to extract the items in the array and assign them a variable&lt;/span&gt;
                                        &lt;span class="c1"&gt;// the array&lt;/span&gt;
&lt;span class="k"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$africa&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$northAmerica&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="nv"&gt;$europe&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$countries&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Now the variables are assigned the values from the array&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$africa&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Output: Nigeria&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$northAmerica&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Output: Canada&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$europe&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Output: Lithuania&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is that something for you:&lt;/p&gt;

&lt;p&gt;If your application makes use of images and you have a situation where you want to get the size of a valid image only file and at the same time return other information about this image like the dimensions, file type and a height/width in text strings,  &lt;code&gt;getimagesize()&lt;/code&gt; can do this. Here is the typical result with this function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="mi"&gt;800&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;           &lt;span class="c1"&gt;// Width of the image in pixels&lt;/span&gt;
  &lt;span class="mi"&gt;600&lt;/span&gt;        &lt;span class="c1"&gt;// Height of the image in pixels&lt;/span&gt;
  &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;         &lt;span class="c1"&gt;// Type of the image (IMAGETYPE_JPEG)&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;23&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="s2"&gt;"width="&lt;/span&gt;&lt;span class="mi"&gt;800&lt;/span&gt;&lt;span class="s2"&gt;" height="&lt;/span&gt;&lt;span class="mi"&gt;600&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="c1"&gt;// Image attributes for html&lt;/span&gt;
  &lt;span class="s2"&gt;"image/jpeg"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// MIME type of the image&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;list()&lt;/code&gt; you can conviniently assign variables to those items in the array and retrieve them in a more readable fashion.&lt;/p&gt;

&lt;p&gt;Since we know that the first element of &lt;code&gt;getimagesize()&lt;/code&gt; function is the image &lt;code&gt;width&lt;/code&gt;, second, is the &lt;code&gt;height&lt;/code&gt;, so and so forth... We can just represent them as variables using  &lt;code&gt;list()&lt;/code&gt; :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$arrayOfImageProperties&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;getimagesize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"geeks.png"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 

&lt;span class="k"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$height&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$imageAttribute&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$mime&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$arrayOfImageProperties&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// display properties &lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;" The width of the image is  : "&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$width&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;br&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"The height of this  image is: "&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$height&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;br&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"The image type is:"&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$type&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;br&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"The image attribute of this image is:"&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;$attr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;The&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="n"&gt;of&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;800&lt;/span&gt;
&lt;span class="nc"&gt;The&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt; &lt;span class="n"&gt;of&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;600&lt;/span&gt;
&lt;span class="nc"&gt;The&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="n"&gt;type&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="nc"&gt;The&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="n"&gt;attribute&lt;/span&gt; &lt;span class="n"&gt;of&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"800"&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"600"&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Shorteeeer syntax:
&lt;/h4&gt;

&lt;p&gt;Shorter syntax to save some key strokes 😉 :&lt;br&gt;
From  php 7.1+ , you can do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$c&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'c'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So incase you go through a codebase and see something like that, it's same as this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt; &lt;span class="k"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nv"&gt;$b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'c'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The end.👋
&lt;/h3&gt;

&lt;p&gt;I believe we can borrow some of these examples play around them and improve our code. See other &lt;a href="https://www.php.net/manual/en/function.list.php#120463"&gt; examples here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>cakephp</category>
      <category>arrays</category>
    </item>
    <item>
      <title>Verifying emails in laravel using laravel ui</title>
      <dc:creator>Chidiebere Chukwudi</dc:creator>
      <pubDate>Mon, 05 Jun 2023 12:26:25 +0000</pubDate>
      <link>https://forem.com/jovialcore/verifying-emails-in-laravel-10-using-laravel-ui-5855</link>
      <guid>https://forem.com/jovialcore/verifying-emails-in-laravel-10-using-laravel-ui-5855</guid>
      <description>&lt;p&gt;Laravel makes building web applications simple and pretty straight forward especially we give credits to it's out-of-the-box functionalities like Authentication Scalffolding.&lt;/p&gt;

&lt;p&gt;In this tutorial, we will be creating our authentication files using &lt;code&gt;laravel ui&lt;/code&gt; package.&lt;/p&gt;

&lt;h2&gt;Install laravel&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;create-project --prefer-dist laravel/laravel app&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From your terminal, CD into &lt;code&gt;app&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Next, go to your &lt;code&gt;.env&lt;/code&gt; file and make the following changes.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mydatabase
DB_USERNAME=root
DB_PASSWORD=&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Adjust those variables where necessary so they reflect your database configuration.&lt;/p&gt;

&lt;h2&gt;Generate Authentication files.&lt;/h2&gt;

&lt;p&gt;Like I mentioned earlier, we'll be generating authentication files using laravel ui package. Install laravel ui :&lt;/p&gt;

&lt;p&gt;&lt;code&gt;composer require laravel/ui&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Scaffold Auth files (In my case, I will be using booststrap)&lt;/p&gt;

&lt;p&gt;&lt;code&gt;php artisan ui bootstrap --auth&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When it's all set, run the commmand &lt;code&gt;php artisan migrate&lt;/code&gt;. So we are migrating to our database users table. It is by default in a fresh laravel installation.&lt;/p&gt;

&lt;p&gt;Start up your application to see what we have done so far in action:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;php artisan serve&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;Email Configuration&lt;/h2&gt;

&lt;p&gt;In this example, I will be using gmail SMTP emailing service.&lt;br&gt;hence you can use your gmail mail account to send mail on behalf of our application. To do this, first, you will need :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your email account username (e.g yourname@gmail.com) and&lt;/li&gt;



&lt;li&gt;App password -- it is the app password we are going to be using as password. Worthy to note is that, to get an app password, you must enable two factor authentication on your gmail account.Follow these intructions to get your app password. &lt;a href="https://support.google.com/mail/answer/185833?hl=en" rel="noopener noreferrer"&gt;How to generate app password&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Following that guide, when you click on "2 factor tab", your app password card (like in the image below) should be at the bottom the page. Remember to fresh page if the "App passwords" section doesn't come up immediately.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa6hunmu42178utkroyi5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa6hunmu42178utkroyi5.png" alt="generte app password" width="800" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Subsequently, you will be prompted to select a device:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F64dgrkvuti66i4kptjp0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F64dgrkvuti66i4kptjp0.png" alt="google app pas" width="800" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy your app password (just like in the screenshot below) and fill them in their respective .env variables :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgy7ij8lplpudmvoegpwk.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgy7ij8lplpudmvoegpwk.jpeg" alt="google app password" width="800" height="562"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=yourusername@gmail.com
MAIL_PASSWORD= yourapppassword
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=codebere@gmail.com
MAIL_FROM_NAME="${APP_NAME}" &lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Model Setup.&lt;/h2&gt;

&lt;p&gt;To proceed, in your &lt;code&gt;Model/User.php&lt;/code&gt; lets add the &lt;code&gt;MustVerifyEmail&lt;/code&gt; class by implementing &lt;code&gt;Illuminate\Contracts\Auth\MustVerifyEmail;&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use Illuminate\Contracts\Auth\MustVerifyEmail;
// other classes
class User extends Authenticatable implements MustVerifyEmail&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm2l4tx4mivf8sfwdkjwz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm2l4tx4mivf8sfwdkjwz.png" alt="User model class" width="800" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Routing&lt;/h2&gt;

&lt;p&gt;The previous steps we have followed has automatically created the neccessary authentication files we may be needing. All we have to do now is prepare a proper routing and that will suffix.&lt;/p&gt;

&lt;h4&gt;Verify Email View Routing&lt;/h4&gt;

&lt;p&gt;Go to your &lt;code&gt;routes/web.php&lt;/code&gt;. Lets first add the routes that redirect authenticated but unverified users to a view file. Notice that we attach an Auth middleware and our route name is &lt;code&gt;verification.notice&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Route::get('/email/verify', function () {

    return view('auth.verify');
})-&amp;gt;middleware('auth')-&amp;gt;name('verification.notice');&lt;/code&gt;&lt;/pre&gt;

&lt;blockquote&gt;
&lt;p&gt;You are not to change the route name as our Auth setup uses the the verified middleware included with Laravel to automatically redirect to that route name if a user has not verified their email address.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;views\auth\verify.blade.php&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4crkzn765cmcd0jhvi45.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4crkzn765cmcd0jhvi45.png" alt="View blade file" width="800" height="293"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;Email Verification Handler&lt;/h4&gt;

&lt;p&gt;Next route we will be defining will be in charge of verifying the email when the user clicks on the link sent to their inbox. Still in your &lt;code&gt;routes/web.php&lt;/code&gt;,&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;// remember to import EmailVerificationRequest class

use Illuminate\Foundation\Auth\EmailVerificationRequest;

Route::get('/email/verify/{id}/{hash}', function (EmailVerificationRequest $r) {
    $r-&amp;gt;fulfill();

    return redirect('/home');
})-&amp;gt;middleware(['auth', 'signed'])-&amp;gt;name('verification.verify');&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In the code above, laravel will use EmailVerificationRequest to validate the request &lt;code&gt;id&lt;/code&gt; and &lt;code&gt;hash&lt;/code&gt; parameters, then call the &lt;code&gt;fufill()&lt;/code&gt; method that marks the authenticated user as verified and dispatches a verified event.&lt;/p&gt;

&lt;p&gt;Email Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fragslj2j6cvyl4uqxa68.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fragslj2j6cvyl4uqxa68.png" alt="email display" width="800" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What if the user deletes the mail we sent or they can't find it ? We want to give them opportunity to request for another verification mail. Here:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use Illuminate\Http\Request;

Route::post('/email/verification-notification', function (Request $r) {

    $r-&amp;gt;user()-&amp;gt;sendEmailVerificationNotification();

    return back()-&amp;gt;with('resent', 'Verification link sent ');
})-&amp;gt;middleware(['auth', 'throttle:6,1'])-&amp;gt;name('verification.send');&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Using this route via a post request, Laravel sends an email notification once again. You can find the responsible blade file in &lt;code&gt;views\auth\verify.blade.php&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa59trczm02cj8514zdmv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa59trczm02cj8514zdmv.png" alt="Image description" width="800" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That should be all. If you find any challenge following this guide please do let me know in the comment section&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/jovial_core" rel="noopener noreferrer"&gt;My Twitter&lt;/a&gt;&lt;br&gt;&lt;a href="https://www.linkedin.com/in/chidiebere-chukwudi-49a982182/" rel="noopener noreferrer"&gt;Linkedin&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
    </item>
    <item>
      <title>Cakephp plugin Development: using custom component in another component.</title>
      <dc:creator>Chidiebere Chukwudi</dc:creator>
      <pubDate>Thu, 20 Apr 2023 11:02:00 +0000</pubDate>
      <link>https://forem.com/jovialcore/cakephp-plugin-development-using-custom-component-in-another-component-e6a</link>
      <guid>https://forem.com/jovialcore/cakephp-plugin-development-using-custom-component-in-another-component-e6a</guid>
      <description>&lt;p&gt;In a traditional cakephp app development, I.e, if  you are not building a pluigin and want to use a custom component in another component, the cakephp docs say you should simply register the component's name in a protected property that has an array value of the custom component's name you want to use, like so : &lt;code&gt;protected $components = ['Existing'];&lt;/code&gt;&lt;br&gt;
Lets get to an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/Controller/Component/CustomComponent.php&lt;/span&gt;
&lt;span class="kn"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;App\Controller\Component&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Cake\Controller\Component&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CustomComponent&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Component&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// The other component your component uses&lt;/span&gt;
    &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="nv"&gt;$components&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Existing'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="c1"&gt;// Execute any other additional setup for your component.&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$config&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nc"&gt;Existing&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// ...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// src/Controller/Component/ExistingComponent.php&lt;/span&gt;
&lt;span class="kn"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;App\Controller\Component&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Cake\Controller\Component&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ExistingComponent&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Component&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// ...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How about a situation where we want to use a custom component in another component this time, in a cakephp plugin context?&lt;br&gt;
Easy. We can simply do that by prefixing the plugin name before the name of the component like so: &lt;code&gt;protected $components = ['PluginName.Existing'];&lt;/code&gt;&lt;br&gt;
Lets get to an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/Controller/Component/CustomComponent.php&lt;/span&gt;
&lt;span class="kn"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;App\Controller\Component&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Cake\Controller\Component&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CustomComponent&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Component&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// The other component your component uses&lt;/span&gt;
    &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="nv"&gt;$components&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'PluginName.Existing'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="c1"&gt;// Execute any other additional setup for your component.&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$config&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nc"&gt;Existing&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// ...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// src/Controller/Component/ExistingComponent.php&lt;/span&gt;
&lt;span class="kn"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;App\Controller\Component&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Cake\Controller\Component&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ExistingComponent&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Component&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// ...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This same principle applies to helpers, behaviours, etc. &lt;/p&gt;

&lt;p&gt;That should be all. This can be confusing sometimes especially in situations where the results you get when you google-search around these concepts often lands you on the traditional cakephp documentation. &lt;/p&gt;

&lt;p&gt;Here is the &lt;a href="https://book.cakephp.org/4/en/plugins.html#components-helpers-and-behaviors" rel="noopener noreferrer"&gt;plugin specific documentation&lt;/a&gt; for more info.&lt;/p&gt;

&lt;p&gt;Also, check out a cakephp plugin for handling cloudinary media uploads I built: &lt;a href="https://github.com/jovialcore/cake-cloudinary" rel="noopener noreferrer"&gt;Cakephp-cloudinary&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm on &lt;a href="https://twitter.com/jovial_core" rel="noopener noreferrer"&gt;twitter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cakephp</category>
      <category>php</category>
    </item>
    <item>
      <title>Empty requests data with multipart/form-data when using fetch api</title>
      <dc:creator>Chidiebere Chukwudi</dc:creator>
      <pubDate>Wed, 14 Sep 2022 20:15:30 +0000</pubDate>
      <link>https://forem.com/jovialcore/empty-request-request-and-request-files-with-multipartform-data-55pl</link>
      <guid>https://forem.com/jovialcore/empty-request-request-and-request-files-with-multipartform-data-55pl</guid>
      <description>&lt;p&gt;It took me quite some time to resolve this isssue. It was an issue with formData and laravel/php not being able to detect the request payload when I dd or dump the request to check.&lt;/p&gt;

&lt;p&gt;There is (and I believe) other solutions but I think this will save you the need to do "messy" workarounds. &lt;/p&gt;

&lt;p&gt;Here you go: &lt;/p&gt;
&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;div class="ltag__stackexchange--header"&gt;
          &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
          &lt;a href="https://stackoverflow.com/questions/71387088/empty-request-request-and-request-files-with-multipart-form-data/71392989#71392989" rel="noopener noreferrer"&gt;
            &lt;span class="title-flare"&gt;answer&lt;/span&gt; re: Empty $request-&amp;gt;request and $request-&amp;gt;files with multipart/form-data
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Mar  8 '22&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/71387088/empty-request-request-and-request-files-with-multipart-form-data/71392989#71392989" rel="noopener noreferrer"&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          8
        &lt;/div&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;DO NOT specify the &lt;code&gt;Content-Type&lt;/code&gt; header yourself, when trying to make such a multipart request. That header needs to include the boundary value (so that the receiver will know how to parse this request) - if you specify it yourself, as just &lt;code&gt;multipart/form-data&lt;/code&gt;, then that will be missing.&lt;/p&gt;
&lt;p&gt;These…&lt;/p&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    &lt;a href="https://stackoverflow.com/questions/71387088/empty-request-request-and-request-files-with-multipart-form-data/71392989#71392989" class="ltag__stackexchange--btn" rel="noopener noreferrer"&gt;Open Full Answer&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>laravel</category>
      <category>php</category>
    </item>
  </channel>
</rss>
