<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Codeigniter &#8211; Learn PHP online</title>
	<atom:link href="https://www.learnphponline.in/category/web-development/php/codeigniter/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.learnphponline.in</link>
	<description>The Best Free Tutorials of Programming Languages in 2019</description>
	<lastBuildDate>Fri, 08 Aug 2025 06:32:35 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.3</generator>
	<item>
		<title>How is PHP Better Than Other Languages: Top Benefits in 2026</title>
		<link>https://www.learnphponline.in/how-is-php-better-than-others/</link>
					<comments>https://www.learnphponline.in/how-is-php-better-than-others/#respond</comments>
		
		<dc:creator><![CDATA[Learn PHP online]]></dc:creator>
		<pubDate>Tue, 16 Jan 2024 00:00:10 +0000</pubDate>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[Latest]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Does FB still use PHP?]]></category>
		<category><![CDATA[Does PHP use a VM?]]></category>
		<category><![CDATA[Is Google written in PHP?]]></category>
		<category><![CDATA[Is hack better than PHP?]]></category>
		<category><![CDATA[Is Javascript similar to PHP?]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Who uses HHVM?]]></category>
		<category><![CDATA[why choose php over other languages]]></category>
		<category><![CDATA[Why do programmers hate PHP?]]></category>
		<guid isPermaLink="false">https://www.learnphponline.in/?p=2817</guid>

					<description><![CDATA[<p>Here we have a question &#8220;How is PHP Better Than others in 2026&#8221; But before the start, There are lots of Technologies in this world for learning or become a Programmer for example Asp.net, JSP, Perl, Ruby, PHP, Python, and many more. But PHP is one of the most famous languages in...</p>
<p>The post <a rel="nofollow" href="https://www.learnphponline.in/how-is-php-better-than-others/">How is PHP Better Than Other Languages: Top Benefits in 2026</a> appeared first on <a rel="nofollow" href="https://www.learnphponline.in">Learn PHP online</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Here we have a question &#8220;<strong>How is PHP Better Than others in 2026</strong>&#8221; But before the start, There are lots of Technologies in this world for learning or become a Programmer for example Asp.net, JSP, Perl, Ruby, PHP, Python, and many more. But PHP is one of the most famous languages in this world Because PHP has a large number of Family and higher jobs. Basically, one best thing about PHP is, you can get online free support within seconds from many portals like <a href="https://www.stackoverflow.com">Stackoverflow.</a></p>
<p>There so many thing in PHP 8.0 to be better than other programming languages. PHP 8 is really good in optimization and securities. also PHP improves their older problem and make itself better for today world of 2026.</p>



<p>also Read: <a href="https://www.learnphponline.in/5-must-have-wordpress-plugins/">Top 5 WordPress Plugins</a>, or <a href="https://www.learnphponline.in/seo-guide/">Rank Your website</a> or<a href="https://www.learnphponline.in/seo-guide/"> SEO Guide</a></p>



<h2 class="wp-block-heading">What are the advantages of php over other languages?</h2>



<p>Basically, I tried to give you the best answer to your question <strong>&#8220;What are the advantages of php over other languages&#8221;</strong> in different points are given below:</p>



<h3 class="wp-block-heading">1. Easy To Learn</h3>



<p>The Best Thing about the PHP which every developer knows. PHP is the simplest Language to learn and start your career. PHP is nearly similar to C and JAVA. Its syntax and way of using are much simple and easy to learn. Especially, one more thing you can easily add or combine HTML, CSS with PHP.</p>



<h3 class="wp-block-heading">2. Open Source Language</h3>



<p>The second good thing about PHP is Open source scripting language. Because PHP is free to use under PHP General Public License and PHP has large community support for its Developers. The open-source <span class="exs">allows</span> <span class="exs">you</span> <span class="exs">to</span> <span class="exs">use</span> <span class="exs">any</span> <span class="exs">text</span> <span class="exs">editor</span> <span class="exs">for</span> <span class="exs">coding</span> <span class="exs">including</span> <span class="exs">Emacs</span>, <span class="exs">jEdit</span>, Notepad++, <span class="exs">etc</span>. <span class="exs">It</span> <span class="exs">doesn</span>&#8216;t <span class="exs">restrict</span> <span class="exs">you</span> <span class="exs">to</span> <span class="exs">develop</span> <span class="exs">a</span> <span class="hy" title="unique">(like nothing else in the world)</span> <span class="exs">app</span>. You can join many platforms like StackOverflow, Quora, etc for quick answers.</p>



<p><strong>Also Read:</strong> <a href="https://www.learnphponline.in/wealthy-affiliate-review/">Earn Money by Affiliate Program: Complete review</a></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>70% websites on all over the Internet ( World wide web) is made by PHP now you can guess &#8220;How is PHP Better than Others in 2026 and Why?&#8221;</p>
</blockquote>



<h3 class="wp-block-heading">3. a Large number of Jobs</h3>



<p>PHP is the 4th most famous Development Programming Language which provides a large no. of jobs all over the world. 4th rank doesn&#8217;t mean it&#8217;s a small amount. Basically, it&#8217;s a bigger scale than I and you expect.</p>



<h3 class="wp-block-heading">4. Security and Safty</h3>



<p>PHP is Highly safe and secure. it&#8217;s 2nd secured language for Web Development because PHP handled every security reason very easily as well as it makes you a safe from the hacker or attackers. The Best Point is that the PHP server is highly secured by default.</p>



<h3 class="wp-block-heading">5. Advance PHP or Frameworks</h3>



<p>Basically, I told you many special things about PHP and now we talking about some Advance things like PHP&#8217;s frameworks. For example:- <strong>CakePHP</strong>, <strong>Zend</strong>, <strong>Symfony</strong>, <strong>CodeIgnator</strong>, <strong><a href="http://www.laravel.com">Laravel</a>,</strong> etc. PHP frameworks make PHP easier and more secure. Working with frameworks is like &#8220;you are riding a high-speed Bike not a cycle&#8221;.</p>



<h3 class="wp-block-heading">6. Integration and tools</h3>



<p>PHP doesn’t work on any strict patterns or with any specific web apps or platforms. The web development with PHP is made much more extensive as the language integrates extremely well with multiple web apps. To name some, PHP integrates with web applications like Pusher, Memcache, <a href="https://www.softprodigy.com/how-to-add-a-package-to-your-node-instance-for-developing-a-mongodb-web-services"><i>MongoDB</i></a>, etc.</p>



<p>Such wide-ranging use and integration of PHP with different web apps make it one of the most widely used programming languages of the web development world. That is why this powerful language fuels 30% of the entire web!</p>



<p>PHP is being used in almost every industry in one form or another. Any expert working in a PHP development company<b> </b>can use the PHP language for web development in a plethora of industries like Government, Health, Banking, IT, Hospitality, Architecture, Large Corporations, and what not!</p>



<h3 class="wp-block-heading">7. Abundance of Frameworks</h3>



<p>No matter what kind of web development task you need to indulge in, you will always find the best-suited PHP framework.</p>



<p>Again, it all goes back to the fact that the PHP community is a huge and diverse community with the solution to every PHP problem. Because of such a vast community, there is a great availability of the PHP frameworks.</p>



<p>So, finding a PHP framework to help you with code reuse, session management, etc. is never a problem. You can get the help of the best PHP development company to find and use the most suitable PHP framework as per your web development needs. Some of the PHP frameworks are Zend, <em>Symfony</em>, Slim, Aiki, Phalcon, CakePHP, Yii, etc.</p>



<p>With all these advantages in hand, there is no denying the fact that PHP is better than most other programming languages. If you’re a beginner in web development or if you’re looking forward to starting your new web development project, you can choose PHP, without a doubt! So, get set and go! Start your proficient web development work with PHP, now!</p>



<h2 class="wp-block-heading">WHY PHP IS GOOD CHOICE FOR WEB DEVELOPMENT</h2>



<figure class="wp-block-image">
<figure style="width: 648px" class="wp-caption aligncenter"><img fetchpriority="high" decoding="async" title="why choose php over other languages" src="https://tekshapers.com/uploads/blog_image/1540537479Untitled-1.png" alt="why choose php over other languages" width="648" height="290" /><figcaption class="wp-caption-text">why choose PHP over other languages</figcaption></figure>
<figcaption></figcaption>
</figure>



<ul class="wp-block-list">
<li>
<h3><strong>Product Development</strong></h3>
</li>
</ul>



<p>These days, to develop or <a href="http://buyyourkart.com/"><strong>create a website</strong></a> is a priority to your business on the internet. The designing and development are the two most promising steps which are crucial. PHP programming language is most widely used for <a href="https://tekshapers.wordpress.com/2018/09/07/what-is-a-web-application/"><strong>website and web application development</strong></a>. It is a general-purpose, server-side scripting language that runs on a web server and is designed for making dynamic pages and applications.</p>
<p>As <a href="http://www.tekshapers.com/product-based-software"><strong>web development services</strong></a> options are secured, fast, and reliable which offers a lot more advantages to make it accessible to a lot of people. It is given a thought to what has made PHP programming language one of the most commonly used languages and is also a good choice for web development. Using PHP as its language has many advantages like it supports <a href="https://en.wikipedia.org/wiki/Oracle_Corporation"><strong>Oracle</strong></a>, <a href="https://en.wikipedia.org/wiki/Sybase"><strong>Sybase</strong></a>, etc. It is used for creating simple functions, methods, and syntax. It also supports a database management system and another open-source database.</p>



<figure class="wp-block-image">
<figure style="width: 650px" class="wp-caption aligncenter"><img decoding="async" title="why choose PHP over other languages" src="https://tekshapers.com/assets/ckfinder/userfiles/images/1_zjp17ASt2EbA_TWwBBP2vQ.png" alt="Advantages of php over other languages" width="650" height="301" /><figcaption class="wp-caption-text">Structure of PHP Language and Its tools</figcaption></figure>
</figure>



<ul class="wp-block-list">
<li>
<h3><strong>Structure of PHP Language</strong></h3>
</li>
</ul>



<p>People in this business need their website to be developed without any well-maintained structure. The PHP application maintenance like maintenance of any machine, website at every period of time needs to be updated. Selecting<a href="http://www.tekshapers.com/blog/Which-is-the-Best-Programming-Language-for-Web-Development"><strong> the best programming language</strong></a> is one that helps you to meet the requirements and develop the functionality which you need at a reasonable cost and within the decent expansion of maintainability and extensibility.</p>
<p>If you are new to the <a href="https://en.wikipedia.org/wiki/WampServer"><strong>web development software</strong></a> environment and are just looking for a place to start, then PHP is not only a great choice but also it is still dominating the server-side web development with well over 50% of the market share. The PHP stands at 415,934 numbers in the top programming language usage distribution in the top 1 million sites, which means it is commonly used as 41.59% of the total languages. This language is capable to minimize code utilization and comes with its memory development function. To collect the object codes from outside is not common as far as the PHP based web application is concerned.</p>



<p>Below are some of the reasons that clearly explain why PHP programming language is the best choice for web development:</p>



<ul class="wp-block-list">
<li>
<h3><strong>Boost Simplicity</strong></h3>
</li>
</ul>



<p>With PHP, coding is like writing an essay in English for a computer to read, except the essay is a piece of code that instructs it to create and run the website in the most efficient manner possible. To create a code in PHP is simple, and though you have rarely heard that some developers complain that this does not build the necessary coding habits in them.</p>



<ul class="wp-block-list">
<li>
<h3><strong>Works Exceptionally</strong></h3>
</li>
</ul>



<p>The latest trends towards adaptive content have created CMS customization which is a crucial competitive need for the business. Adaptive content is content personalized for individual visitors to the website for creating a one-to-one experience for the visitors. This is only possible if the website&#8217;s code can be customized and integrated with the help of CMS.</p>



<ul class="wp-block-list">
<li>
<h3><strong>Increased Programming Talent</strong></h3>
</li>
</ul>



<p>This programming language is often used to create a large pool of talent to choose from for modifications and building and lowering the cost per hour for those services. To update your site in the future, it would be a better choice to select and<strong> hiring staff</strong> a member for the task or work with an alternate provider than the one who built your site.</p>



<figure class="wp-block-image">
<figure style="width: 653px" class="wp-caption aligncenter"><img decoding="async" title="why choose PHP over other languages" src="https://tekshapers.com/assets/ckfinder/userfiles/images/pphp%201.png" alt="Advantages of php over other languages" width="653" height="573" /><figcaption class="wp-caption-text">The structure that shows: How is PHP Better Than others</figcaption></figure>
</figure>



<ul class="wp-block-list">
<li>
<h3><strong>Embed-ability</strong></h3>
</li>
</ul>



<p>The recent trend in adaptive content has made the responsive website and fluid grid systems even more pertinent for organizations. <a href="https://en.wikipedia.org/wiki/HTML5"><strong>HTML5</strong></a> is the unquestioned industry to develop a highly dynamic and responsive website. This is where PHP surfaces as the language which allows its code to be easily embedded into HTML language.</p>



<ul class="wp-block-list">
<li>
<h3><strong>Standard library</strong></h3>
</li>
</ul>



<p>The extent of its standard library only makes the differentiation between the good programming languages from a great one. Libraries play an important role to simplify and speeding the data processing ability of the language. It offers extensive support for <a href="https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol"><strong>HTTP</strong></a> fetching, regular expressions, URL parsing, and database drivers. It is completely true that the library is incoherent, but the community’s on it.</p>



<h2 class="wp-block-heading"><strong>Importance of PHP in Web Development</strong></h2>



<p>The release of PHP modern web developers can be determined with the help of usage statistics posted on various websites. In addition to this, the in-demand programming language, PHP is also more popular than other programming languages. At present, nearly about 82% of the websites are using PHP as a server-side programming language. Below are several features that are given that describes the importance of PHP in web development:</p>



<h4 class="wp-block-heading"><strong>Performance</strong></h4>



<p>Nowadays, most of the users abandon the website which takes more than 3 seconds to load. Hence, the developers have to explore ways to keep the visitors engaged by gaining the website loading speed. It comes with JIT (Just in Time) engine which compiles the PHP code into machine language for better engaging results.</p>
<blockquote>
<h4>why website performance is important?</h4>
<p><b>Website performance</b> is incredibly <b>important</b> because customers generally think load times are slower than they actually are. This means you need to be doing all you can to make your <b>website</b> load as fast as possible. <a href="https://www.siteuptime.com/blog/2017/11/21/speed-matters-the-importance-of-website-performance-testing-tools/">Siteuptime</a></p>
</blockquote>



<h4 class="wp-block-heading"><strong>Compatibility</strong></h4>



<p>This language works seamlessly with the major operating system, database, and web servers. It supports an operating system like <strong><a href="https://en.wikipedia.org/wiki/Linux">Linux</a>, <a href="https://en.wikipedia.org/wiki/Solaris_(operating_system)">Solaris</a></strong>, etc. At the same time, the programmers also have an option for choosing a number of databases. It also supports some of the commonly used protocols like HTTP, POP3, LDAP COM, etc.</p>



<h4 class="wp-block-heading"><strong>Flexibility</strong></h4>



<p>It is one of the most flexible web programming languages. It also enables the programmers for making changes to the code during different stages of development. They can easily add new features or functionality to the website even after writing the code. Changes can also be done in existing code and can also be modified to add new features to the website</p>



<h4 class="wp-block-heading"><strong>Conclusion for &#8220;Why PHP is better than Others in 2024&#8221;:</strong></h4>



<p>The PHP programmers still have to put extra time and effort into writing the web application in PHP. They have to avail the resources which are provided by various frameworks and <a href="https://en.wikipedia.org/wiki/Content_management_system"><strong>content management system</strong></a> for reducing the development time significantly. Choosing PHP language for <a href="https://hubpages.com/technology/How-to-Hire-a-Web-Development-Company"><strong>website development services</strong></a> will surely provide you excellent results to build a website for your organization.</p>
<blockquote>
<h4>Latest Version of PHP</h4>
<p>PHP 8.0 is a major update of the PHP language. It contains many new features and optimizations including named arguments, union types, attributes, constructor property promotion, match expression, null safe operator, JIT, and improvements in the type system, error handling, and consistency.</p>
</blockquote>
<h4>What is meant by language development?</h4>
<p><b>Language development</b> refers to the process through which children acquire, or learn a <b>language</b>. <b>Language</b> can be thought of in two main categories: receptive and expressive. Receptive refers to a child&#8217;s ability to understand the communication of other people, including spoken words, gestures, and written words.</p>
<h4>What is web development?</h4>
<p>Web development is the work involved in developing a Web site for the Internet or an intranet. Web development can range from developing a simple single static page of plain text to complex Web-based Internet applications, electronic businesses, and social network services. <a class="ruhjFe NJLBac fl" href="https://en.wikipedia.org/wiki/Web_development" data-ved="2ahUKEwj74eKmyIDuAhV2yDgGHeCUB3UQmhMwG3oECDUQAg">Wikipedia</a></p>
<h4>What does a Web developer do?</h4>
<p><b>Web developers</b> design and create <b>websites</b>. They are responsible for the look of the site. They are also responsible for the site&#8217;s technical aspects, such as its performance and capacity, which are measures of a <b>website&#8217;s</b> speed and how much traffic the site <b>can</b> handle. <a href="https://www.bls.gov/ooh/computer-and-information-technology/web-developers.htm">Bsl.gov</a></p>
<h2>Summary for why choose PHP over other languages</h2>
<p>Basically, PHP 8 is still the fastest, and 80% of websites developed by PHP till now. That&#8217;s the big reason PHP is the most stable language for web development and there is not a replacement for it. Python will also never takes a place of PHP.</p>



<p>Read more: <a href="https://www.learnphponline.in/wordpress-vs-blogger-2019/">WordPress vs Blogger</a>, <a href="https://www.learnphponline.in/php-training/php-arrays/">Learn PHP</a>, <a href="https://www.learnphponline.in/best-cms-wordpress-vs-joomla/">Best CMS (WordPress or Joomla or Other)</a>, <a href="https://www.learnphponline.in/best-programming-language-blogging/">Best Programming Language to start blogging</a></p>
<figure id="attachment_11986" aria-describedby="caption-attachment-11986" style="width: 1768px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-11986 size-full" src="https://www.learnphponline.in/wp-content/uploads/2021/03/php-8.jpg" alt="Advantages of php over other languages" width="1768" height="800" srcset="https://www.learnphponline.in/wp-content/uploads/2021/03/php-8.jpg 1768w, https://www.learnphponline.in/wp-content/uploads/2021/03/php-8-300x136.jpg 300w, https://www.learnphponline.in/wp-content/uploads/2021/03/php-8-1024x463.jpg 1024w, https://www.learnphponline.in/wp-content/uploads/2021/03/php-8-768x348.jpg 768w, https://www.learnphponline.in/wp-content/uploads/2021/03/php-8-1536x695.jpg 1536w" sizes="(max-width: 1768px) 100vw, 1768px" /><figcaption id="caption-attachment-11986" class="wp-caption-text">Advantages of php over other languages</figcaption></figure>
<div class="pvc_clear"></div><p id="pvc_stats_2817" class="pvc_stats all  " data-element-id="2817" style=""><i class="pvc-stats-icon medium" aria-hidden="true"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="chart-bar" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-chart-bar fa-w-16 fa-2x"><path fill="currentColor" d="M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z" class=""></path></svg></i> <img loading="lazy" decoding="async" width="16" height="16" alt="Loading" src="https://www.learnphponline.in/wp-content/plugins/page-views-count/ajax-loader-2x.gif" border=0 /></p><div class="pvc_clear"></div><p>The post <a rel="nofollow" href="https://www.learnphponline.in/how-is-php-better-than-others/">How is PHP Better Than Other Languages: Top Benefits in 2026</a> appeared first on <a rel="nofollow" href="https://www.learnphponline.in">Learn PHP online</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.learnphponline.in/how-is-php-better-than-others/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>DocuSign Embedded signing in Core PHP, CodeIgniter 4, Laravel 8</title>
		<link>https://www.learnphponline.in/docusign-embedded-signing-in-core-php-codeigniter-4-laravel-8/</link>
					<comments>https://www.learnphponline.in/docusign-embedded-signing-in-core-php-codeigniter-4-laravel-8/#respond</comments>
		
		<dc:creator><![CDATA[Learn PHP online]]></dc:creator>
		<pubDate>Wed, 08 Sep 2021 07:26:18 +0000</pubDate>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[xampp]]></category>
		<category><![CDATA[DocuSign API]]></category>
		<category><![CDATA[DocuSIgn ESign]]></category>
		<category><![CDATA[Embedded Signing]]></category>
		<category><![CDATA[php]]></category>
		<guid isPermaLink="false">https://www.learnphponline.in/?p=12062</guid>

					<description><![CDATA[<p>DocuSign Embedded Signing in Core PHP, CodeIgniter 4 or Laravel 8: I will show you step by step guide to help you in quick start. Here, I mentioned every detail that you need to handle bugs errors and many more things. Today we will see how we can do an embedded signing...</p>
<p>The post <a rel="nofollow" href="https://www.learnphponline.in/docusign-embedded-signing-in-core-php-codeigniter-4-laravel-8/">DocuSign Embedded signing in Core PHP, CodeIgniter 4, Laravel 8</a> appeared first on <a rel="nofollow" href="https://www.learnphponline.in">Learn PHP online</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><strong>DocuSign Embedded Signing in Core PHP, CodeIgniter 4 or Laravel 8:</strong> I will show you step by step guide to help you in quick start. Here, I mentioned every detail that you need to handle bugs errors and many more things.</p>
<p>Today we will see how we can do an embedded signing with <b>DocuSign in Core PHP or any Other</b>. If you are reading my blog which means you also want to integrate DocuSign with your Application. Please follow the below instruction to integrate <b>DocuSign in one shot</b>.</p>
<h2 id="step-1">Step: 1 Create a developer account on DocuSign</h2>
<p>I Know, You that stuff very well and you already your <a href="https://developers.docusign.com/">DocuSign developer account</a>. But dude let me clear few things for you that will help you to understand the DocuSign API and structure.</p>
<p><img loading="lazy" decoding="async" class=" wp-image-12065 aligncenter" src="https://www.learnphponline.in/wp-content/uploads/2021/09/docusign-Api-Credentials.png" alt="docusign Api Credentials" width="877" height="401" srcset="https://www.learnphponline.in/wp-content/uploads/2021/09/docusign-Api-Credentials.png 1366w, https://www.learnphponline.in/wp-content/uploads/2021/09/docusign-Api-Credentials-300x137.png 300w, https://www.learnphponline.in/wp-content/uploads/2021/09/docusign-Api-Credentials-1024x469.png 1024w, https://www.learnphponline.in/wp-content/uploads/2021/09/docusign-Api-Credentials-768x351.png 768w" sizes="(max-width: 877px) 100vw, 877px" /></p>
<p>Credits: <a href="https://blog.codehunger.in">codeHunger</a></p>
<p>Here, You need to create APP Like DemoApp for your project. <strong>Account id</strong>, <strong>Integration key ( Client_id / ds_client_id), Secret Key and Refer Url. </strong>These 3 things are very necessary.</p>
<p><strong>Suggestion:</strong> I personally Suggest you to create ds_config.php file with all configuration constant to handle the whole API.</p>
<p><img loading="lazy" decoding="async" class="wp-image-12067 aligncenter" src="https://www.learnphponline.in/wp-content/uploads/2021/09/ds_config-file-for-DocuSign.jpg" alt="ds_config file for DocuSign" width="864" height="559" srcset="https://www.learnphponline.in/wp-content/uploads/2021/09/ds_config-file-for-DocuSign.jpg 1300w, https://www.learnphponline.in/wp-content/uploads/2021/09/ds_config-file-for-DocuSign-300x194.jpg 300w, https://www.learnphponline.in/wp-content/uploads/2021/09/ds_config-file-for-DocuSign-1024x662.jpg 1024w, https://www.learnphponline.in/wp-content/uploads/2021/09/ds_config-file-for-DocuSign-768x497.jpg 768w" sizes="(max-width: 864px) 100vw, 864px" /></p>
<p><img loading="lazy" decoding="async" class=" wp-image-12066 aligncenter" src="https://www.learnphponline.in/wp-content/uploads/2021/09/DocuSign-App-Details.png" alt="DocuSign App Details" width="895" height="409" srcset="https://www.learnphponline.in/wp-content/uploads/2021/09/DocuSign-App-Details.png 1366w, https://www.learnphponline.in/wp-content/uploads/2021/09/DocuSign-App-Details-300x137.png 300w, https://www.learnphponline.in/wp-content/uploads/2021/09/DocuSign-App-Details-1024x469.png 1024w, https://www.learnphponline.in/wp-content/uploads/2021/09/DocuSign-App-Details-768x351.png 768w" sizes="(max-width: 895px) 100vw, 895px" /></p>
<h2 id="step-2">Step: 2 Create an DocuSign Folder on Xampp.</h2>
<p>create a folder in your Xampp or Server. here, I also suggest, test on xampp and than use composer. if you don&#8217;t know about don&#8217;t worry just follow my steps.</p>
<p>First install composer from <a href="https://getcomposer.org/download/">https://getcomposer.org/download/</a>. than you need to install DocuSign Library using Command.</p>
<p>after installing composer, open your in the right folder for docusign.</p>
<h2 id="block-ec7816de-99b5-40c7-8ecb-45c927175168">Step: 3 Install DocuSign Package</h2>
<pre><span style="color: #ff0000;">Composer require docusign/esign-client</span></pre>
<p>&nbsp;</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-12068" src="https://www.learnphponline.in/wp-content/uploads/2021/09/docusign-API-Directory-or-folder.jpg" alt="docusign API Directory or folder" width="1381" height="365" srcset="https://www.learnphponline.in/wp-content/uploads/2021/09/docusign-API-Directory-or-folder.jpg 1381w, https://www.learnphponline.in/wp-content/uploads/2021/09/docusign-API-Directory-or-folder-300x79.jpg 300w, https://www.learnphponline.in/wp-content/uploads/2021/09/docusign-API-Directory-or-folder-1024x271.jpg 1024w, https://www.learnphponline.in/wp-content/uploads/2021/09/docusign-API-Directory-or-folder-768x203.jpg 768w" sizes="(max-width: 1381px) 100vw, 1381px" /><br />
After this Command, you have <strong>vendor folder</strong> which contain packages,<strong> src folder</strong> which contain our Base Class which handle all API, and <strong>doc folder</strong> contain PDF file which need to signature. and <strong>index.php</strong> file is base file which can be Laravel routes, CodeIgniter routes or controller,  or any file which handle routes. and ds_config.php as i already told you above.</p>
<p><strong>suggestion:</strong> you can use .env in replacement of ds_config if you are using Laravel or any other framework.</p>
<p>&nbsp;</p>
<h2 id="block-ec7816de-99b5-40c7-8ecb-45c927175168">Step: 4 Collect all code and Files as Given below</h2>
<p><strong>index.php file code:</strong></p>
<div>
<pre>&lt;?php 

require_once dirname(__FILE__). '/ds_config.php';
require_once dirname(__FILE__). '/src/DocuSignController.php';

$docuSign = new DocuSignController();

if (session_status() == PHP_SESSION_NONE) {
    session_start();
}

$authData = @$_SESSION['authData'];
if(@$_GET['page']=='connect'){
   $docuSign-&gt;connect(); 
}elseif(@$_GET['page']=='sign'){

   $docuSign-&gt;signDocument();
}
else{
  if(@$_GET['code'] &amp;&amp; ( !array_key_exists('authData',$_SESSION) || property_exists($authData,'error') )){
        $docuSign-&gt;callback();
  }
  //session_destroy();
  $docuSign-&gt;index();
}
?&gt;</pre>
</div>
<p><strong>Src folder code and structure:</strong></p>
<p><img loading="lazy" decoding="async" class=" wp-image-12069 aligncenter" src="https://www.learnphponline.in/wp-content/uploads/2021/09/src-folder-files.jpg" alt="" width="844" height="443" srcset="https://www.learnphponline.in/wp-content/uploads/2021/09/src-folder-files.jpg 1769w, https://www.learnphponline.in/wp-content/uploads/2021/09/src-folder-files-300x157.jpg 300w, https://www.learnphponline.in/wp-content/uploads/2021/09/src-folder-files-1024x537.jpg 1024w, https://www.learnphponline.in/wp-content/uploads/2021/09/src-folder-files-768x403.jpg 768w, https://www.learnphponline.in/wp-content/uploads/2021/09/src-folder-files-1536x806.jpg 1536w" sizes="(max-width: 844px) 100vw, 844px" /></p>
<p>Here in src folder, we have 2 files one is index.php ( view ) and another DocuSignController.php Class which contain all API. In CodeIgniter you can use it as custom library, in Laravel you can use it as Controller or Service.</p>
<p><strong>So, Here Index.php ( view ) code:</strong></p>
<div>
<pre>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
  &lt;title&gt;Docusign Integration Example&lt;/title&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
  &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;div class="container"&gt;
   &lt;div class="card"&gt;
    &lt;div class="card-header"&gt;
        PHP and DocuSIgn
      &lt;/div&gt;
      &lt;div class="card-body"&gt;
        &lt;h5 class="card-title"&gt;Docusign &lt;/h5&gt;
        &lt;p class="card-text"&gt;Click the button below to connect your appication with docusign&lt;/p&gt;
        &lt;?php
        if (@$_SESSION['message'] =='success'){
        ?&gt;
          &lt;a href="index.php?page=sign" class="btn btn-primary"&gt;Click to sign document&lt;/a&gt;
        &lt;?php
        }
        else{ 
        ?&gt;
          &lt;a href="index.php?page=connect" class="btn btn-primary"&gt;Connect Docusign&lt;/a&gt;
        &lt;?php
         }
        ?&gt;
  &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p><strong>DocuSignController.php class code:</strong></p>
<div>
<pre>&lt;?php
require_once dirname(__DIR__). '/vendor/autoload.php';
use DocuSign\eSign\Configuration;
use DocuSign\eSign\Api\EnvelopesApi;
use DocuSign\eSign\Client\ApiClient;

class DocuSignController {        
    /** hold config value */
    private $config;
    private $signer_client_id = 1000; # Used to indicate that the signer will use embedded
    /** Specific template arguments */
    private $args;

    public function index(){
      require_once dirname(__FILE__).'/views/index.php';    
    }

    
    /**
     * Connect your application to docusign
     *
     * @return url
     */
    public function connect()
    {
        try {
            $params = [
                'response_type' =&gt; 'code',
                'scope' =&gt; 'signature',
                'client_id' =&gt; $GLOBALS['DS_CONFIG']['ds_client_id'],
                'redirect_uri' =&gt;$GLOBALS['DS_CONFIG']['app_url'],
            ];
            $queryBuild = http_build_query($params);
            $url = "https://account-d.docusign.com/oauth/auth?";
            $botUrl = $url . $queryBuild;
            header('Location:'.$botUrl);
           
        } catch (Exception $e) {
            $_SESSION['message'] = 'error';
            return false;
        }
    }
    public function callback()
    {
        $code = $_GET['code'];
        $client_id =  $GLOBALS['DS_CONFIG']['ds_client_id'];
        $client_secret =  $GLOBALS['DS_CONFIG']['ds_client_secret'];
        $integrator_and_secret_key = "Basic " . utf8_decode(base64_encode("{$client_id}:{$client_secret}"));
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,  $GLOBALS['DS_CONFIG']['authorization_server'].'/oauth/token');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        $post = array(
            'grant_type' =&gt; 'authorization_code',
            'code' =&gt; $code,
        );
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
        $headers = array();
        $headers[] = 'Cache-Control: no-cache';
        $headers[] = "authorization: $integrator_and_secret_key";
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        $result = curl_exec($ch);
        if (curl_errno($ch)) {
            echo 'Error:' . curl_error($ch);
        }

        curl_close($ch);
        $decodedData = json_decode($result);
        $_SESSION['authData'] = $decodedData;
        $_SESSION['message'] = 'success';
        return true;
    }
    
    public function signDocument()
    {       
      try{
        $this-&gt;args = $this-&gt;getTemplateArgs();
        $args = $this-&gt;args;
        $envelope_args = $args["envelope_args"];
        
        # Create the envelope request object
        $envelope_definition = $this-&gt;make_envelope($args["envelope_args"]);
        $envelope_api = $this-&gt;getEnvelopeApi();
      
        # Call Envelopes::create API method
        # Exceptions will be caught by the calling function
        
        $api_client = new \DocuSign\eSign\client\ApiClient($this-&gt;config);
        $envelope_api = new \DocuSign\eSign\Api\EnvelopesApi($api_client);
        
        $results = $envelope_api-&gt;createEnvelope($args['account_id'], $envelope_definition);
       
        $envelope_id = $results-&gt;getEnvelopeId();        
        $authentication_method = 'None'; # How is this application authenticating
        # the signer? See the `authenticationMethod' definition
        # https://developers.docusign.com/esign-rest-api/reference/Envelopes/EnvelopeViews/createRecipient
        
        $recipient_view_request = new \DocuSign\eSign\Model\RecipientViewRequest([
            'authentication_method' =&gt; $authentication_method,
            'client_user_id' =&gt; $envelope_args['signer_client_id'],
            'recipient_id' =&gt; '1',
            'return_url' =&gt; $envelope_args['ds_return_url'],
            'user_name' =&gt; 'SuryaPratap', 'email' =&gt; 'soroutlove1996@gmail.com'
        ]);
        $results = $envelope_api-&gt;createRecipientView($args['account_id'], $envelope_id,$recipient_view_request);
        return header('Location:'.$results['url']);
        } catch (Exception $e) {
            echo "&lt;pre&gt;";
            print_r($e);
        }
        
    }

    private function make_envelope($args)
    {   
        
        $filename = 'World_Wide_Corp_lorem.pdf';
        $demo_docs_path = dirname(__DIR__)."/doc/".$filename;
        $arrContextOptions=array(
            "ssl"=&gt;array(
                "verify_peer"=&gt;false,
                "verify_peer_name"=&gt;false,
            ),
        );  
        $content_bytes = file_get_contents($demo_docs_path,false, stream_context_create($arrContextOptions));
        // dd($content_bytes);
        $base64_file_content = base64_encode($content_bytes);
        // dd($base64_file_content);
        # Create the document model
        $document = new \DocuSign\eSign\Model\Document([# create the DocuSign document object
        'document_base64' =&gt; $base64_file_content,
            'name' =&gt; 'Example document', # can be different from actual file name
            'file_extension' =&gt; 'pdf', # many different document types are accepted
            'document_id' =&gt; 1, # a label used to reference the doc
        ]);
        # Create the signer recipient model
        $signer = new \DocuSign\eSign\Model\Signer([# The signer
        'email' =&gt; 'soroutlove1996@gmail.com', 'name' =&gt; 'SuryaPratap',
            'recipient_id' =&gt; "1", 'routing_order' =&gt; "1",
            # Setting the client_user_id marks the signer as embedded
            'client_user_id' =&gt; $args['signer_client_id'],
        ]);
        # Create a sign_here tab (field on the document)
        $sign_here = new \DocuSign\eSign\Model\SignHere([# DocuSign SignHere field/tab
        'anchor_string' =&gt; '/sn1/', 'anchor_units' =&gt; 'pixels',
            'anchor_y_offset' =&gt; '10', 'anchor_x_offset' =&gt; '20',
        ]);
        # Add the tabs model (including the sign_here tab) to the signer
        # The Tabs object wants arrays of the different field/tab types
        $signer-&gt;settabs(new \DocuSign\eSign\Model\Tabs(['sign_here_tabs' =&gt; [$sign_here]]));
        # Next, create the top level envelope definition and populate it.
        $envelope_definition = new \DocuSign\eSign\Model\EnvelopeDefinition([
            'email_subject' =&gt; "Please sign this Broker Agreement document - MortgageStreet",
            'documents' =&gt; [$document],
            # The Recipients object wants arrays for each recipient type
            'recipients' =&gt; new \DocuSign\eSign\Model\Recipients(['signers' =&gt; [$signer]]),
            'status' =&gt; "sent", # requests that the envelope be created and sent.
        ]);

        return $envelope_definition;
    }

    /**
     * Getter for the EnvelopesApi
     */
    public function getEnvelopeApi(): EnvelopesApi
    {   
        $this-&gt;config = new Configuration();
        $this-&gt;config-&gt;setHost($this-&gt;args['base_path']);
        $this-&gt;config-&gt;addDefaultHeader('Authorization', 'Bearer ' . $this-&gt;args['ds_access_token']);    
        $this-&gt;apiClient = new ApiClient($this-&gt;config);
        return new EnvelopesApi($this-&gt;apiClient);
    }
    /**
     * Get specific template arguments
     *
     * @return array
     */
    private function getTemplateArgs()
    {   
        $envelope_args = [
            'signer_client_id' =&gt; $this-&gt;signer_client_id,
            'ds_return_url' =&gt; $GLOBALS['DS_CONFIG']['app_url']."?status=success",
        ];

        $args = [
            'account_id' =&gt;  $GLOBALS['DS_CONFIG']['account_id'],
            'base_path' =&gt; $GLOBALS['DS_CONFIG']['api_url'],
            'ds_access_token' =&gt; $_SESSION['authData']-&gt;access_token,
            'envelope_args' =&gt; $envelope_args
        ];
        return $args;
      }

} // end of class

</pre>
<p><strong>Note: You must have to add callback URL in your docusign , to get your  application get authenticated</strong>.</p>
<p>See the below image.</p>
<p><img loading="lazy" decoding="async" class="wp-image-12070 aligncenter" src="https://www.learnphponline.in/wp-content/uploads/2021/09/image-6.png" alt="" width="816" height="373" srcset="https://www.learnphponline.in/wp-content/uploads/2021/09/image-6.png 1366w, https://www.learnphponline.in/wp-content/uploads/2021/09/image-6-300x137.png 300w, https://www.learnphponline.in/wp-content/uploads/2021/09/image-6-1024x469.png 1024w, https://www.learnphponline.in/wp-content/uploads/2021/09/image-6-768x351.png 768w" sizes="(max-width: 816px) 100vw, 816px" /></p>
</div>
<h2 id="#step-9">Step-9 Test the integration</h2>
</div>
<p>&nbsp;</p>
<div>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-12075" src="https://www.learnphponline.in/wp-content/uploads/2021/09/start-connecting-to-DocuSign.jpg" alt="DocuSign Embedded Signing in PHP" width="833" height="200" srcset="https://www.learnphponline.in/wp-content/uploads/2021/09/start-connecting-to-DocuSign.jpg 1912w, https://www.learnphponline.in/wp-content/uploads/2021/09/start-connecting-to-DocuSign-300x72.jpg 300w, https://www.learnphponline.in/wp-content/uploads/2021/09/start-connecting-to-DocuSign-1024x246.jpg 1024w, https://www.learnphponline.in/wp-content/uploads/2021/09/start-connecting-to-DocuSign-768x185.jpg 768w, https://www.learnphponline.in/wp-content/uploads/2021/09/start-connecting-to-DocuSign-1536x370.jpg 1536w" sizes="(max-width: 833px) 100vw, 833px" />Click on connect DocuSign, you will redirect to DocuSign’s official website where they told you to enter your DocuSign email and password, after giving your credentials you will come back to your application with the below image.</p>
</div>
<p>&nbsp;</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-12076" src="https://www.learnphponline.in/wp-content/uploads/2021/09/after-connect.jpg" alt="DocuSign Embedded Signing" width="799" height="191" srcset="https://www.learnphponline.in/wp-content/uploads/2021/09/after-connect.jpg 1913w, https://www.learnphponline.in/wp-content/uploads/2021/09/after-connect-300x72.jpg 300w, https://www.learnphponline.in/wp-content/uploads/2021/09/after-connect-1024x246.jpg 1024w, https://www.learnphponline.in/wp-content/uploads/2021/09/after-connect-768x184.jpg 768w, https://www.learnphponline.in/wp-content/uploads/2021/09/after-connect-1536x369.jpg 1536w" sizes="(max-width: 799px) 100vw, 799px" /></p>
<p>After connect, if everything is correct than you will get code variable in url. and than click on sign document. after this you need to authorized DocuSign with admin account details.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-12072" src="https://www.learnphponline.in/wp-content/uploads/2021/09/Capture.jpg" alt="DocuSign Embedded Signing" width="736" height="327" srcset="https://www.learnphponline.in/wp-content/uploads/2021/09/Capture.jpg 1912w, https://www.learnphponline.in/wp-content/uploads/2021/09/Capture-300x133.jpg 300w, https://www.learnphponline.in/wp-content/uploads/2021/09/Capture-1024x455.jpg 1024w, https://www.learnphponline.in/wp-content/uploads/2021/09/Capture-768x341.jpg 768w, https://www.learnphponline.in/wp-content/uploads/2021/09/Capture-1536x683.jpg 1536w" sizes="(max-width: 736px) 100vw, 736px" /></p>
<p><figure id="attachment_12074" aria-describedby="caption-attachment-12074" style="width: 820px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-12074" src="https://www.learnphponline.in/wp-content/uploads/2021/09/Capture3.jpg" alt="DocuSign Embedded Signing" width="820" height="416" srcset="https://www.learnphponline.in/wp-content/uploads/2021/09/Capture3.jpg 1920w, https://www.learnphponline.in/wp-content/uploads/2021/09/Capture3-300x152.jpg 300w, https://www.learnphponline.in/wp-content/uploads/2021/09/Capture3-1024x519.jpg 1024w, https://www.learnphponline.in/wp-content/uploads/2021/09/Capture3-768x390.jpg 768w, https://www.learnphponline.in/wp-content/uploads/2021/09/Capture3-1536x779.jpg 1536w" sizes="(max-width: 820px) 100vw, 820px" /><figcaption id="caption-attachment-12074" class="wp-caption-text">DocuSign Embedded Signing</figcaption></figure></p>
<p>&nbsp;</p>
<p>I hope, this blog helps you to install docuSign. at time i was so confused with docuSign documentation and git code examples. but now you have everything.</p>
<p>&nbsp;</p>
<h2>You can also download DocuSign API code from my Github</h2>
<div class="otfe-fe-form-wrapper">

	<div class="otfe-fe-message-wrapper otfe-fe-message-wrapper-3"></div>

	<form method="post" action="" class="otfd-fe-form" id="otfd-fe-form-3">
				<div class="otfd-fe-form-row">
			<label>Your email address</label>
			<input type="email" name="email" class="otfd-fe-email otfd-fe-input" value="" placeholder="Your email address" />
		</div>
		
							
		<div class="otfd-fe-form-row otfd-fe-form-errors otfd-hidden">
			<p>
				Please fix the errors above and try to submit again			</p>
		</div>
		<input type="hidden" id="otfd_fe_nonce_3" name="otfd_fe_nonce_3" value="1caf32a9e9" /><input type="hidden" name="_wp_http_referer" value="/category/web-development/php/codeigniter/feed/" />		<input type="hidden" name="otfd_fe_action" class="otfd_fe_action" value="email_link" />
		<div class="otfd-fe-form-row">
			<a href="#" class="otfd-fe-form-submit" data-otfdid="3">Download</a>
		</div>
	</form>

</div>
<div class="pvc_clear"></div>
<p id="pvc_stats_12062" class="pvc_stats all  " data-element-id="12062" style=""><i class="pvc-stats-icon medium" aria-hidden="true"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="chart-bar" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-chart-bar fa-w-16 fa-2x"><path fill="currentColor" d="M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z" class=""></path></svg></i> <img loading="lazy" decoding="async" width="16" height="16" alt="Loading" src="https://www.learnphponline.in/wp-content/plugins/page-views-count/ajax-loader-2x.gif" border=0 /></p>
<div class="pvc_clear"></div>
<p>The post <a rel="nofollow" href="https://www.learnphponline.in/docusign-embedded-signing-in-core-php-codeigniter-4-laravel-8/">DocuSign Embedded signing in Core PHP, CodeIgniter 4, Laravel 8</a> appeared first on <a rel="nofollow" href="https://www.learnphponline.in">Learn PHP online</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.learnphponline.in/docusign-embedded-signing-in-core-php-codeigniter-4-laravel-8/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CodeIgniter routing problem &#8211; Showing Homepage but not others</title>
		<link>https://www.learnphponline.in/codeigniter-routing-problem-showing-only-homepage-but-not-others/</link>
					<comments>https://www.learnphponline.in/codeigniter-routing-problem-showing-only-homepage-but-not-others/#respond</comments>
		
		<dc:creator><![CDATA[Learn PHP online]]></dc:creator>
		<pubDate>Fri, 09 Jul 2021 08:40:44 +0000</pubDate>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ci]]></category>
		<category><![CDATA[CodeIgniter routing problem]]></category>
		<category><![CDATA[routes]]></category>
		<guid isPermaLink="false">https://www.learnphponline.in/?p=12047</guid>

					<description><![CDATA[<p>CodeIgniter routing problem: This is not a very common problem. It comes in few cases but the problem is a problem and finding a solution is very necessary. I have a very useful solution for you and it will definitely help you to solve the Codeigniter 3 &#38; 4 routes problem. This...</p>
<p>The post <a rel="nofollow" href="https://www.learnphponline.in/codeigniter-routing-problem-showing-only-homepage-but-not-others/">CodeIgniter routing problem &#8211; Showing Homepage but not others</a> appeared first on <a rel="nofollow" href="https://www.learnphponline.in">Learn PHP online</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><strong>CodeIgniter routing problem: </strong>This is not a very common problem. It comes in few cases but the problem is a problem and finding a solution is very necessary. I have a very useful solution for you and it will definitely help you to solve the <a href="https://www.learnphponline.in/change-codeigniter-environment-variable/">Codeigniter</a> 3 &amp; 4 routes problem.</p>
<p>This problem comes when you are using the Nigix Linux server or Apache Linux server. and also your project is in a subdirectory Like: <em>/var/www/example.com/app</em>  or  /<em>var/www/html/app</em>.</p>
<p>&nbsp;</p>
<p>As you Codeigniter routes working <em>.htaccess</em> file and the problem is also here. but changing anything related to<em> the .htaccess</em> file you need to answer few things.</p>
<h3><strong>My CodeIgniter config.php file should like given below:</strong></h3>
<div>
<pre>$base_url   = (isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER['HTTP_HOST'];
$base_url  .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
$config['base_url'] = $base_url;
<em>$config['index</em>page’] = “;
$config['uri_protocol’] = '<em>REQUEST_URI</em>’;</pre>
</div>
<p>&nbsp;</p>
<h3><strong>My CodeIgniter .htaccess file should be like given below:</strong></h3>
<pre>RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST<em>FILENAME} !-f
RewriteCond %{REQUEST</em>FILENAME} !-d
RewriteCond $1 !^(index.php|assets|upload|robots.txt|.<em>.css)
RewriteRule ^(.</em>)$ index.php?/$1 [L]</pre>
<p>&nbsp;</p>
<p>So, if this is all good with your project that means your code and <a href="https://stackoverflow.com/questions/13170819/what-is-htaccess-file"><em>.htaccess</em></a> file is good and you need to access the server terminal or server, support team.</p>
<p>Also, read about <a href="https://www.learnphponline.in/top-blogger-in-india-in-2021/">the top richest Indian blogger</a> and how to earn money via blogging.</p>
<p>&nbsp;</p>
<h3>For Apache Linux server:</h3>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-12049 size-full" src="https://www.learnphponline.in/wp-content/uploads/2021/07/linux-server.jpeg" alt="CodeIgniter routing problem" width="470" height="205" srcset="https://www.learnphponline.in/wp-content/uploads/2021/07/linux-server.jpeg 470w, https://www.learnphponline.in/wp-content/uploads/2021/07/linux-server-300x131.jpeg 300w" sizes="(max-width: 470px) 100vw, 470px" /></p>
<p>I believe that you need to enable <code>AllowOverride</code> in order for your <code>.htaccess</code> to take effect.</p>
<p>To do that you need to add the following in your Vhost:</p>
<pre>&lt;Directory /var/www/learnphponline.in/app&gt;
   Options Indexes FollowSymLinks
   AllowOverride All
   Require all granted
&lt;/Directory&gt;</pre>
<p>&nbsp;</p>
<p><strong>Note:-</strong> that you need to update the <code><span class="highlight">/var/www/learnphponline.in/public</span></code> part to match your document root. Then run a config test and restart Apache. After that, the rules that you have in your <code>.htaccess</code> file would take effect.</p>
<p>&nbsp;</p>
<h3>For Nginx, PHP-FPM:</h3>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-12048" src="https://www.learnphponline.in/wp-content/uploads/2021/07/nginx.png" alt="CodeIgniter routing problem" width="647" height="324" srcset="https://www.learnphponline.in/wp-content/uploads/2021/07/nginx.png 1720w, https://www.learnphponline.in/wp-content/uploads/2021/07/nginx-300x150.png 300w, https://www.learnphponline.in/wp-content/uploads/2021/07/nginx-1024x513.png 1024w, https://www.learnphponline.in/wp-content/uploads/2021/07/nginx-768x385.png 768w, https://www.learnphponline.in/wp-content/uploads/2021/07/nginx-1536x770.png 1536w" sizes="(max-width: 647px) 100vw, 647px" /></p>
<p>find the file <em>nginx.conf</em> and add this code:</p>
<pre><code>location / {
    # nginx won't display 404, we leave this to Rails
    try_files $uri @passenger;
}

location @passenger {
   passenger_app_root /var/www/learnphponline.in/;
   passenger_document_root /var/www/learnphponline.in/app/;
   passenger_enabled on;
}</code></pre>
<p>&nbsp;</p>
<h2>Summary for the CodeIgniter routing problem</h2>
<p>Hope this will help you or at least you get an idea of what issue you are facing. Migration from one server to another or from localhost to live server will create this kind of issue. But if you have proper support from the server team or admin then it will be very easy for you to solve this.</p>
<p>&nbsp;</p>
<p>Also, read about the <a href="https://www.learnphponline.in/programing-language-for-freelancing/">Top 10 best freelancing</a> languages or <a href="https://www.learnphponline.in/top-10-programming-languages/">Top 10 programming languages.</a></p>
<div class="pvc_clear"></div>
<p id="pvc_stats_12047" class="pvc_stats all  " data-element-id="12047" style=""><i class="pvc-stats-icon medium" aria-hidden="true"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="chart-bar" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-chart-bar fa-w-16 fa-2x"><path fill="currentColor" d="M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z" class=""></path></svg></i> <img loading="lazy" decoding="async" width="16" height="16" alt="Loading" src="https://www.learnphponline.in/wp-content/plugins/page-views-count/ajax-loader-2x.gif" border=0 /></p>
<div class="pvc_clear"></div>
<p>The post <a rel="nofollow" href="https://www.learnphponline.in/codeigniter-routing-problem-showing-only-homepage-but-not-others/">CodeIgniter routing problem &#8211; Showing Homepage but not others</a> appeared first on <a rel="nofollow" href="https://www.learnphponline.in">Learn PHP online</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.learnphponline.in/codeigniter-routing-problem-showing-only-homepage-but-not-others/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to get a Controller and Method Name in Codeigniter 4</title>
		<link>https://www.learnphponline.in/get-controller-and-method-name-codeigniter/</link>
					<comments>https://www.learnphponline.in/get-controller-and-method-name-codeigniter/#respond</comments>
		
		<dc:creator><![CDATA[Learn PHP online]]></dc:creator>
		<pubDate>Thu, 21 Jan 2021 05:41:11 +0000</pubDate>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Uncategorised]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Codeigniter 4]]></category>
		<category><![CDATA[Codeigniter routes]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[get controller name in Codeigniter]]></category>
		<category><![CDATA[Method name]]></category>
		<guid isPermaLink="false">https://www.learnphponline.in/?p=11750</guid>

					<description><![CDATA[<p>Get a Controller and Method Name in Codeigniter 4: As we Know Codeigniter 4 is recently launched and we have a lack of blogs and Tutorials on its. So, I am here to help you out to get the model name and controller name using routes services. If you want to implement...</p>
<p>The post <a rel="nofollow" href="https://www.learnphponline.in/get-controller-and-method-name-codeigniter/">How to get a Controller and Method Name in Codeigniter 4</a> appeared first on <a rel="nofollow" href="https://www.learnphponline.in">Learn PHP online</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><strong>Get a Controller and Method Name in Codeigniter 4: </strong> As we Know <a href="https://codeigniter4.github.io/">Codeigniter 4</a> is recently launched and we have a lack of blogs and Tutorials on its. So, I am here to help you out to get the model name and controller name using routes services.</p>



<p>If you want to implement conditional code based on the class or method, you need to get the current class and method name in CodeIgniter. Using the Router Class in CodeIgniter, you can easily get the current controller and method name. The Router class helps to parses URIs and determines to route. The <span style="color: #ff0000;">$router-&gt;controllerName()</span> and <span style="color: #ff0000;">$router-&gt; methodName()</span> method of Router class can be used to read them <code>class</code> and <code>method</code> property in CodeIgniter.</p>
<p>CodeIgniter 4 is a powerful PHP framework that provides developers with a flexible and efficient way to build web applications. However, due to its relatively recent release, there is a scarcity of available blogs and tutorials. In this comprehensive blog post, we aim to address this issue by providing a detailed guide on how to retrieve the controller and method names in CodeIgniter 4 using the routes service. This information can be immensely helpful when implementing conditional code based on the class or method being accessed.</p>
<p>You can Also Read, <a href="https://www.learnphponline.in/php-training/php-functions-objects/">Php Function and methods</a>.</p>
<h2>Understanding the Router Service in CodeIgniter 4:</h2>
<p>The Router class in CodeIgniter 4 plays a crucial role in parsing URIs and determining how to route requests. It provides convenient methods to access information about the current controller and method being executed.</p>
<p><strong>Step 1:</strong> Accessing the Router Service: To begin, you need to access the router service, which can be done using the following code snippet:</p>
<pre>$router = service('router');</pre>



<p>&nbsp;</p>



<div class="wp-block-image">
<figure class="aligncenter size-large is-resized">
<figure id="attachment_11752" aria-describedby="caption-attachment-11752" style="width: 489px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-11752" src="https://www.learnphponline.in/wp-content/uploads/2020/07/download.jpg" alt="get a Controller and Method Name in Codeigniter 4" width="489" height="221" srcset="https://www.learnphponline.in/wp-content/uploads/2020/07/download.jpg 334w, https://www.learnphponline.in/wp-content/uploads/2020/07/download-300x136.jpg 300w" sizes="(max-width: 489px) 100vw, 489px" /><figcaption id="caption-attachment-11752" class="wp-caption-text">get a Controller and Method Name in Codeigniter 4</figcaption></figure>
<figcaption></figcaption>
</figure>
</div>



<h2 class="wp-block-heading">Get or Fetch Controller Name in Codeigniter 4</h2>



<p>For the Controller name, You need to call router service. Then, you will use controllerName() function.</p>



<pre class="wp-block-preformatted">$router = service('router'); 
$controller  = $router-&gt;controllerName();  </pre>



<p>The <code>$controller</code> variable will now contain the name of the current controller, which you can use for further processing or conditional code execution.</p>
<h2 class="wp-block-heading">Get or Fetch Method Name in Codeigniter 4</h2>



<p>Similarly, you can retrieve the name of the method being executed within the controller using the <code>methodName()</code> method of the router service:</p>



<pre class="wp-block-preformatted">$router = service('router');
$method = $router-&gt;methodName();
</pre>



<p>The <code>$method</code> variable will now hold the name of the current method, allowing you to perform specific actions or logic based on the method being called.</p>
<p>&nbsp;</p>
<h3 class="wp-block-heading">Summary of Codeigniter 4 Routes Service to getting Method or Controller name</h3>



<p>CodeIgniter 4 offers a range of core classes that are accessible as services, providing a simple and consistent way to access their functionalities. Apart from the router service, you can explore other services such as the logger service (<code>$logger = service('logger')</code>) and the routes service (<code>$routes = service('routes')</code>).</p>



<pre class="wp-block-preformatted">$logger <strong>=</strong> service('logger');
$routes = service('routes');</pre>



<p>Also, Read <a href="https://www.learnphponline.in/change-codeigniter-environment-variable/">How to change Codeigniter 4 Environment Variable</a> and <a href="https://www.learnphponline.in/how-is-php-better-than-others/">How PHP is Better than Other Languages</a>.</p>
<h3>Conclusion:</h3>
<p>In this comprehensive blog post, we delved into the process of retrieving the controller and method names in CodeIgniter 4 using the routes service. By following the outlined steps, you can easily access this information, empowering you to implement conditional code based on the class or method being executed. We hope this detailed tutorial has provided valuable insights and will assist you in your CodeIgniter 4 development journey.</p>
<p>For further reading, we recommend exploring our articles on PHP functions and methods to enhance your understanding. Additionally, consider learning about how PHP compares to other programming languages to gain a broader perspective. Furthermore, we have a detailed guide on changing CodeIgniter 4 environment variables, which can be beneficial in your projects. Stay tuned for more comprehensive and insightful content!</p>
<p>&nbsp;</p>
<h2>Read, How PHP 8 is better than other programming languages in 2024</h2>
<p>Here we have a question “<strong>How is PHP Better Than others in 2024</strong>” But before the start, There are lots of Technologies in this world for learning or become a Programmer for example Asp.net, JSP, Perl, Ruby, PHP, Python, and many more. But PHP is one of the most famous languages in this world Because PHP has a large number of Family and higher jobs. Basically, one best thing about PHP is, you can get online free support within seconds from many portals like <a href="https://www.stackoverflow.com/">Stackoverflow.</a></p>
<p>Read Full Blog on &#8220;<a href="https://www.learnphponline.in/how-is-php-better-than-others/">https://www.learnphponline.in/how-is-php-better-than-others/</a>&#8220;</p>
<figure id="attachment_11986" aria-describedby="caption-attachment-11986" style="width: 649px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-11986" src="https://www.learnphponline.in/wp-content/uploads/2021/03/php-8.jpg" alt="How is PHP Better Than others in 2024" width="649" height="294" srcset="https://www.learnphponline.in/wp-content/uploads/2021/03/php-8.jpg 1768w, https://www.learnphponline.in/wp-content/uploads/2021/03/php-8-300x136.jpg 300w, https://www.learnphponline.in/wp-content/uploads/2021/03/php-8-1024x463.jpg 1024w, https://www.learnphponline.in/wp-content/uploads/2021/03/php-8-768x348.jpg 768w, https://www.learnphponline.in/wp-content/uploads/2021/03/php-8-1536x695.jpg 1536w" sizes="(max-width: 649px) 100vw, 649px" /><figcaption id="caption-attachment-11986" class="wp-caption-text">How is PHP Better Than others in 2024</figcaption></figure>
<div class="pvc_clear"></div><p id="pvc_stats_11750" class="pvc_stats all  " data-element-id="11750" style=""><i class="pvc-stats-icon medium" aria-hidden="true"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="chart-bar" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-chart-bar fa-w-16 fa-2x"><path fill="currentColor" d="M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z" class=""></path></svg></i> <img loading="lazy" decoding="async" width="16" height="16" alt="Loading" src="https://www.learnphponline.in/wp-content/plugins/page-views-count/ajax-loader-2x.gif" border=0 /></p><div class="pvc_clear"></div><p>The post <a rel="nofollow" href="https://www.learnphponline.in/get-controller-and-method-name-codeigniter/">How to get a Controller and Method Name in Codeigniter 4</a> appeared first on <a rel="nofollow" href="https://www.learnphponline.in">Learn PHP online</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.learnphponline.in/get-controller-and-method-name-codeigniter/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to set a Dynamic Base URL in CodeIgniter 4 &#8211; Change base_url()</title>
		<link>https://www.learnphponline.in/set-dynamic-base-url-in-codeigniter-4/</link>
					<comments>https://www.learnphponline.in/set-dynamic-base-url-in-codeigniter-4/#respond</comments>
		
		<dc:creator><![CDATA[Learn PHP online]]></dc:creator>
		<pubDate>Sat, 16 Jan 2021 08:53:29 +0000</pubDate>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Codeigniter 4 base url]]></category>
		<category><![CDATA[Dynamic base url]]></category>
		<category><![CDATA[php]]></category>
		<guid isPermaLink="false">https://www.learnphponline.in/?p=11865</guid>

					<description><![CDATA[<p>Setting dynamic base URLs is an essential aspect of web development that enables developers to easily switch between different environments such as development, testing, and production. The article &#8220;Set Dynamic Base URL in CodeIgniter 4&#8221; published on learnphponline.in provides a step-by-step guide on how to set up dynamic base URLs in CodeIgniter...</p>
<p>The post <a rel="nofollow" href="https://www.learnphponline.in/set-dynamic-base-url-in-codeigniter-4/">How to set a Dynamic Base URL in CodeIgniter 4 &#8211; Change base_url()</a> appeared first on <a rel="nofollow" href="https://www.learnphponline.in">Learn PHP online</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Setting dynamic base URLs is an essential aspect of web development that enables developers to easily switch between different environments such as development, testing, and production. The article &#8220;Set Dynamic Base URL in CodeIgniter 4&#8221; published on learnphponline.in provides a step-by-step guide on how to set up dynamic base URLs in CodeIgniter 4. However, the article can be improved by incorporating some key suggestions.</p>
<p><strong>Change/set a dynamic base URL in CodeIgniter:</strong> is very easy and reliable. Especially, in CodeIgniter 4 version. If we didn&#8217;t configure base_url() or site_url() then CodeIgniter find it automatically but its not perfect solution. sometimes, the automatic base URL creates a problem for developers. You can also <a class="row-title" href="https://www.learnphponline.in/change-codeigniter-environment-variable/" aria-label="“How to Set/Change Codeigniter 4 Environment Variable to Development or Production” (Edit)"> Set/Change Codeigniter 4 Environment Variable to Development or Production</a></p>
<p>When <tt class="docutils literal"><span class="pre">$config['base_url']</span></tt> is not set, CodeIgniter 4 tries to automatically detect what your website’s base URL is. This is done purely for convenience when you are starting the development of a new application.</p>
<p>Auto-detection of the base URL is never reliable and also has security implications, which is why you should <strong>always</strong> have it manually configured in CodeIgniter 4.</p>
<p><a href="https://codeigniter.com/user_guide/index.html">Read Codeigniter 4 Full Tutorial Guide </a>OR <a href="https://codeigniter.com/">Download Codeigniter 4</a></p>
<p>&nbsp;</p>
<h3>Why do we need to set a dynamic base URL in CodeIgniter 4?</h3>
<p>Basically, In most cases, we need to shift our CodeIgniter application from a Local Server to a Live Server and vice-versa. So, every time we have to change the base URL from the config.php file. It takes a little bit more time and also increases 1 more step every time. A good developer already has solutions to save time.</p>
<p><figure style="width: 413px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-medium" src="https://1.bp.blogspot.com/-QU_vPGW6xOs/V_QCAHzKBKI/AAAAAAAABcE/aTymf3nivqY9kpyf6rnz7HrBrAr-AUFDQCLcB/w1200-h630-p-k-no-nu/codeigniter-get-current-url-base-url.png" alt="Set Dynamic Base URL in CodeIgniter 4" width="413" height="216" /><figcaption class="wp-caption-text">Base URL in CodeIgniter</figcaption></figure></p>
<p>So here, I have a solution for you. you can try this code on \application\config\config.php:</p>
<p><strong>Step1: Get HTTP or HTTPS from URL</strong></p>
<p><code class="php variable">$config</code><code class="php plain">[</code><code class="php string">'base_url'</code><code class="php plain">] = ((isset(</code><code class="php variable">$_SERVER</code><code class="php plain">[</code><code class="php string">'HTTPS'</code><code class="php plain">]) &amp;&amp; </code><code class="php variable">$_SERVER</code><code class="php plain">[</code><code class="php string">'HTTPS'</code><code class="php plain">] == </code><code class="php string">"on"</code><code class="php plain">) ? </code><code class="php string">"https"</code> <code class="php plain">: </code><code class="php string">"http"</code><code class="php plain">);</code></p>
<p>this line of code will help you to detect the HTTP or HTTPS. this is also a major issue in many cases. because when you SSL certificated expired or user tries request with HTTP then fixed URL return error or creates a bug.</p>
<p><strong>Step2: Get Host or domain name from URL</strong></p>
<p><code class="php variable">$config</code><code class="php plain">[</code><code class="php string">'base_url'</code><code class="php plain">] .= </code><code class="php string">"://"</code><code class="php plain">.</code><code class="php variable">$_SERVER</code><code class="php plain">[</code><code class="php string">'HTTP_HOST'</code><code class="php plain">];</code></p>
<p>&nbsp;</p>
<p><strong>Step3: get Script Name from URL</strong></p>
<p><code class="php variable">$config</code><code class="php plain">[</code><code class="php string">'base_url'</code><code class="php plain">] .= </code><code class="php functions">str_replace</code><code class="php plain">(</code><code class="php functions">basename</code><code class="php plain">(</code><code class="php variable">$_SERVER</code><code class="php plain">[</code><code class="php string">'SCRIPT_NAME'</code><code class="php plain">]),</code><code class="php string">""</code><code class="php plain">,</code><code class="php variable">$_SERVER</code><code class="php plain">[</code><code class="php string">'SCRIPT_NAME'</code><code class="php plain">]);</code></p>
<p>So, here I concatenated or combined 3 lines in $config[&#8216;base_url&#8217;] to set customizable base URL in CodeIgniter. I think this is the easiest and the best solution for CodeIgniter 4 dynamic base URL or Site URL.</p>
<div>
<pre id="highlighter_526760" class="syntaxhighlighter php">$config['base_url'] = ((isset($_SERVER['HTTPS']) &amp;&amp; $_SERVER['HTTPS'] == "on") ? "https" : "http"); 
$config['base_url'] .= "://".$_SERVER['HTTP_HOST']; 
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);</pre>
</div>
<p>Also read, <a class="row-title" href="https://www.learnphponline.in/get-controller-and-method-name-codeigniter/" aria-label="“How to get a Controller and Method Name in Codeigniter 4” (Edit)">How to get a Controller and Method Name in Codeigniter 4</a></p>
<p>Conclusion: In conclusion, the article &#8220;Set Dynamic Base URL in CodeIgniter 4&#8221; published on learnphponline.in can be improved by incorporating some key suggestions. By providing clear and concise instructions, visual aids, and error handling tips, the article can become more engaging and helpful to readers who are looking to set up dynamic base URLs in CodeIgniter 4. We hope that these suggestions help improve the article and make it more beneficial to the web development community.</p>
<p>In summary, by following these suggestions, the article &#8220;Set Dynamic Base URL in CodeIgniter 4&#8221; can become an even more valuable resource for developers looking to set up dynamic base URLs in CodeIgniter 4.</p>
<div class="pvc_clear"></div>
<p id="pvc_stats_11865" class="pvc_stats all  " data-element-id="11865" style=""><i class="pvc-stats-icon medium" aria-hidden="true"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="chart-bar" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-chart-bar fa-w-16 fa-2x"><path fill="currentColor" d="M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z" class=""></path></svg></i> <img loading="lazy" decoding="async" width="16" height="16" alt="Loading" src="https://www.learnphponline.in/wp-content/plugins/page-views-count/ajax-loader-2x.gif" border=0 /></p>
<div class="pvc_clear"></div>
<p>The post <a rel="nofollow" href="https://www.learnphponline.in/set-dynamic-base-url-in-codeigniter-4/">How to set a Dynamic Base URL in CodeIgniter 4 &#8211; Change base_url()</a> appeared first on <a rel="nofollow" href="https://www.learnphponline.in">Learn PHP online</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.learnphponline.in/set-dynamic-base-url-in-codeigniter-4/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Set/Change Codeigniter 4 Environment Variable to Development or Production</title>
		<link>https://www.learnphponline.in/change-codeigniter-environment-variable/</link>
					<comments>https://www.learnphponline.in/change-codeigniter-environment-variable/#respond</comments>
		
		<dc:creator><![CDATA[Learn PHP online]]></dc:creator>
		<pubDate>Fri, 08 Jan 2021 15:30:31 +0000</pubDate>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Change Codeigniter Environment]]></category>
		<category><![CDATA[Codeigniter 4 Environment]]></category>
		<category><![CDATA[Set Codeigniter 4 Environment]]></category>
		<guid isPermaLink="false">https://www.learnphponline.in/?p=11734</guid>

					<description><![CDATA[<p>Change Codeigniter 4 Environment Variable to Development or Production: As we all know Codeigniter is very famous and very successful for small or mid-level projects and Also, CodeIgniter is a powerful PHP framework with a very small footprint, built for developers who need a simple and elegant toolkit to create full-featured web...</p>
<p>The post <a rel="nofollow" href="https://www.learnphponline.in/change-codeigniter-environment-variable/">How to Set/Change Codeigniter 4 Environment Variable to Development or Production</a> appeared first on <a rel="nofollow" href="https://www.learnphponline.in">Learn PHP online</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><strong>Change Codeigniter 4 Environment Variable to Development or Production:</strong> As we all know Codeigniter is very famous and very successful for small or mid-level projects and Also, CodeIgniter is a powerful PHP framework with a very small footprint, built for developers who need a simple and elegant toolkit to create full-featured web applications.</p>



<h3 class="wp-block-heading">What Design Pattern Codeigniter 4 Follows?</h3>



<p>CodeIgniter 4 is based on the Model-View-Controller (MVC) development pattern. MVC is a software approach that separates application logic from presentation. In practice, it permits your web pages to contain minimal scripting since the presentation is separate from the PHP scripting</p>



<div class="wp-block-image">
<figure class="aligncenter size-large">
<figure id="attachment_11735" aria-describedby="caption-attachment-11735" style="width: 762px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-11735" src="https://www.learnphponline.in/wp-content/uploads/2020/07/mvc-Model-view-controller-1024x658.png" alt=" Change Codeigniter 4 Environment Variable" width="762" height="490" srcset="https://www.learnphponline.in/wp-content/uploads/2020/07/mvc-Model-view-controller-1024x658.png 1024w, https://www.learnphponline.in/wp-content/uploads/2020/07/mvc-Model-view-controller-300x193.png 300w, https://www.learnphponline.in/wp-content/uploads/2020/07/mvc-Model-view-controller-768x493.png 768w, https://www.learnphponline.in/wp-content/uploads/2020/07/mvc-Model-view-controller.png 1470w" sizes="(max-width: 762px) 100vw, 762px" /><figcaption id="caption-attachment-11735" class="wp-caption-text">MVC (MODEL &#8211; VIEW &#8211; CONTROLLER) Design Patter</figcaption></figure>
</figure>
</div>



<p>&nbsp;</p>



<h2 class="wp-block-heading">How many Environments in Codeigniter 4?</h2>



<p>Now Lets, Talk about Codeigniter 4 Environment and its Variable. Actually, Codeigniter has 3 different environments:</p>



<ol class="wp-block-list">
<li><strong>Production mode:</strong> It stops all display an error and help the user to make the application live.</li>
<li><strong>Development mode:</strong> It works when the application in development mode or the Developer working on it.</li>
<li><strong>Testing mode:</strong> As we all know testing mode is the next stage after the development completed.</li>
</ol>



<h2 class="wp-block-heading">How do we set or change the Codeigniter 4 Environment?</h2>



<p>Developers often desire different system behavior depending on whether an application is running in a development or production environment.</p>



<p>For example, verbose error output is something that would be useful while developing an application, but it may also pose a security issue when “live”. In development environments, you might want additional tools loaded that you don’t in production environments, etc.</p>



<p>So, there are many ways to handling environment variables but here are two simple and quicks ways:</p>



<p>1: <strong>ENV FILE: </strong>You can change the environment variable through the .env file founded in your base directory. The simplest method to set the variable is in your <a href="https://codeigniter.com/user_guide/general/configuration.html">.env file</a>.</p>



<p><code>CI_ENVIRONMENT <strong>=</strong> development</code></p>



<p>2: <strong>Index.php</strong>: You can change the environment variable through index.php in the root directory. It the simple and used by most developers.</p>



<p><code>define("ENVIRONMENT","development");</code></p>



<p>3: <strong>Apache</strong>: This server variable can be set in your <code>.htaccess</code> file or Apache config using <a href="https://httpd.apache.org/docs/2.2/mod/mod_env.html#setenv">SetEnv</a>.</p>



<p><code>SetEnv CI_ENVIRONMENT development</code></p>



<p>4: <strong>Nginx</strong>: Under Nginx, you must pass the environment variable through the <code>fastcgi_params</code> in order for it to show up under the $_SERVER variable. This allows it to work on the virtual-host level, instead of using env to set it for the entire server, though that would work fine on a dedicated server. You would then modify your server config to something like:</p>



<pre> 
<strong>server</strong> {  
   <strong>server_name</strong> localhost;    
   <strong>include</strong>     conf/defaults.conf;     
   <strong>root</strong>        /var/www;     
   <strong>location</strong>    ~* \.php$ 
          {         
             <strong>fastcgi_param</strong> CI_ENVIRONMENT "production";         
             <strong>include</strong> conf/fastcgi-php.conf;    
        } 
} 
</pre>



<h2 class="wp-block-heading">Summary, <strong>Change Codeigniter 4 Environment Variable to Development or Production</strong></h2>



<p>As we saw Codeigniter have many ways to change environment variable to development or production. but the easiest and simplest way is to set a constant via the index.php file.</p>



<p><strong>Tips for Codeigniter 4 Security</strong>: Always CSRF ( Cross-site request forgery ) token for form data submission. it helps to make your data secure and stop outside injections.</p>



<h3 class="wp-block-heading">What is CSRF?</h3>



<p>Cross-site request forgery, also known as one-click attack or session riding and abbreviated as <strong>CSRF</strong> (sometimes pronounced sea-surf) or XSRF, is a type of malicious exploit of a website where unauthorized commands are transmitted from a user that the web application trusts.</p>



<figure class="wp-block-image size-large" data-amp-noloading="true" data-amp-lightbox="true"><img loading="lazy" decoding="async" width="800" height="472" class="wp-image-11737 aligncenter" src="https://www.learnphponline.in/wp-content/uploads/2020/07/csrf-cross-site-request-forgery.png" alt=" Change Codeigniter 4 Environment Variable" srcset="https://www.learnphponline.in/wp-content/uploads/2020/07/csrf-cross-site-request-forgery.png 800w, https://www.learnphponline.in/wp-content/uploads/2020/07/csrf-cross-site-request-forgery-300x177.png 300w, https://www.learnphponline.in/wp-content/uploads/2020/07/csrf-cross-site-request-forgery-768x453.png 768w" sizes="(max-width: 800px) 100vw, 800px" /></figure>



<h3 class="wp-block-heading">What is PHP 8 Constant?</h3>



<p><a href="https://www.learnphponline.in/php-training/php-constant/">PHP Constants</a> are similar to variables, holding information to be accessed later, except that they are what they sound like—constant. In other words, once you have defined one, its value is set for the remainder of the program and cannot be altered. Read more about <a href="https://www.learnphponline.in/php-training/php-constant/">PHP Constants</a>.</p>
<figure id="attachment_11797" aria-describedby="caption-attachment-11797" style="width: 326px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-11797 " src="https://www.learnphponline.in/wp-content/uploads/2017/12/php_8_released-300x188.png" alt="PHP 8 Constant" width="326" height="204" srcset="https://www.learnphponline.in/wp-content/uploads/2017/12/php_8_released-300x188.png 300w, https://www.learnphponline.in/wp-content/uploads/2017/12/php_8_released-1024x640.png 1024w, https://www.learnphponline.in/wp-content/uploads/2017/12/php_8_released-768x480.png 768w, https://www.learnphponline.in/wp-content/uploads/2017/12/php_8_released.png 1280w" sizes="(max-width: 326px) 100vw, 326px" /><figcaption id="caption-attachment-11797" class="wp-caption-text">PHP 8 Constant</figcaption></figure>
<p>&nbsp;</p>



<h3>what is the config file in CodeIgniter?</h3>
<p>By default, <b>CodeIgniter</b> has one primary <b>config file</b>, located at application/<b>config</b>/<b>config</b>.php. If you do create your own <b>config files</b> use the same format as the primary one, storing your items in an array called $<b>config</b>.</p>
<p>&nbsp;</p>
<h2>CodeIgniter 4 VS Codeigniter 3</h2>
<p>CodeIgniter 4 is very different from 3 and below you will see a little about the main differences between them.</p>
<h3>#1 &#8211; Support for PHP versions</h3>
<p>To use CodeIgniter 4 the minimum PHP version required is 7.2, while with CodeIgniter 3 it is possible to use from version 5.6 (which has already been completely discontinued).</p>
<h3><a class="anchor" href="https://dev.to/jonathanlamim/10-differences-between-codeigniter-3-and-4-5526#2-directory-organization" name="2-directory-organization"></a>#2 &#8211; Directory organization</h3>
<p>The file structure is completely different. CodeIgniter 4 has its structure organized in 5 directories: /app<code>,</code>/system<code>,</code>/public<code>,</code>/writable<code>,</code>/tests<code>. While CodeIgniter 3 is organized in 2 directories:</code>/application<code>and</code>/system`.</p>
<h3>#3 &#8211; Use of namespaces</h3>
<p>CodeIgniter 4 is written entirely in PHP 7 and makes use of namespaces, while CodeIgniter 3 does not use namespaces.</p>
<h3><a class="anchor" href="https://dev.to/jonathanlamim/10-differences-between-codeigniter-3-and-4-5526#4-autoloading" name="4-autoloading"></a>#4 &#8211; Autoloading</h3>
<p>CodeIgniter 4 has a much more efficient autoload process, and one of the factors that help is the use of namespaces. While in CodeIgniter 3 it is necessary to manually configure most of the files to be loaded.</p>
<h3><a class="anchor" href="https://dev.to/jonathanlamim/10-differences-between-codeigniter-3-and-4-5526#5-use-of-entities" name="5-use-of-entities"></a>#5 &#8211; Use of entities</h3>
<p>CodeIgniter 4 has native support for the use of Entities (entities) that help in structuring the database part of an application, representing the existing columns in the tables. CodeIgniter 3 did not have this feature and anyone who needed to use it needed to use third-party libraries and make adjustments to the file upload to support it.</p>
<p>Read More <a href="https://dev.to/jonathanlamim/10-differences-between-codeigniter-3-and-4-5526">on Codeigniter 4 vs Codeigniter 3.</a></p>
<div class="pvc_clear"></div><p id="pvc_stats_11734" class="pvc_stats all  " data-element-id="11734" style=""><i class="pvc-stats-icon medium" aria-hidden="true"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="chart-bar" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-chart-bar fa-w-16 fa-2x"><path fill="currentColor" d="M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z" class=""></path></svg></i> <img loading="lazy" decoding="async" width="16" height="16" alt="Loading" src="https://www.learnphponline.in/wp-content/plugins/page-views-count/ajax-loader-2x.gif" border=0 /></p><div class="pvc_clear"></div><p>The post <a rel="nofollow" href="https://www.learnphponline.in/change-codeigniter-environment-variable/">How to Set/Change Codeigniter 4 Environment Variable to Development or Production</a> appeared first on <a rel="nofollow" href="https://www.learnphponline.in">Learn PHP online</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.learnphponline.in/change-codeigniter-environment-variable/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
